| 1 |
/* ./src_f77/zher.f -- translated by f2c (version 20030320). |
| 2 |
You must link the resulting object file with the libraries: |
| 3 |
-lf2c -lm (in that order) |
| 4 |
*/ |
| 5 |
|
| 6 |
#include <punc/vf2c.h> |
| 7 |
|
| 8 |
/* Subroutine */ int zher_(char *uplo, integer *n, doublereal *alpha, |
| 9 |
doublecomplex *x, integer *incx, doublecomplex *a, integer *lda, |
| 10 |
ftnlen uplo_len) |
| 11 |
{ |
| 12 |
/* System generated locals */ |
| 13 |
integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5; |
| 14 |
doublereal d__1; |
| 15 |
doublecomplex z__1, z__2; |
| 16 |
|
| 17 |
/* Builtin functions */ |
| 18 |
void d_cnjg(doublecomplex *, doublecomplex *); |
| 19 |
|
| 20 |
/* Local variables */ |
| 21 |
static integer i__, j, ix, jx, kx, info; |
| 22 |
static doublecomplex temp; |
| 23 |
extern logical lsame_(char *, char *, ftnlen, ftnlen); |
| 24 |
extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); |
| 25 |
|
| 26 |
/* .. Scalar Arguments .. */ |
| 27 |
/* .. Array Arguments .. */ |
| 28 |
/* .. */ |
| 29 |
|
| 30 |
/* Purpose */ |
| 31 |
/* ======= */ |
| 32 |
|
| 33 |
/* ZHER performs the hermitian rank 1 operation */ |
| 34 |
|
| 35 |
/* A := alpha*x*conjg( x' ) + A, */ |
| 36 |
|
| 37 |
/* where alpha is a real scalar, x is an n element vector and A is an */ |
| 38 |
/* n by n hermitian matrix. */ |
| 39 |
|
| 40 |
/* Parameters */ |
| 41 |
/* ========== */ |
| 42 |
|
| 43 |
/* UPLO - CHARACTER*1. */ |
| 44 |
/* On entry, UPLO specifies whether the upper or lower */ |
| 45 |
/* triangular part of the array A is to be referenced as */ |
| 46 |
/* follows: */ |
| 47 |
|
| 48 |
/* UPLO = 'U' or 'u' Only the upper triangular part of A */ |
| 49 |
/* is to be referenced. */ |
| 50 |
|
| 51 |
/* UPLO = 'L' or 'l' Only the lower triangular part of A */ |
| 52 |
/* is to be referenced. */ |
| 53 |
|
| 54 |
/* Unchanged on exit. */ |
| 55 |
|
| 56 |
/* N - INTEGER. */ |
| 57 |
/* On entry, N specifies the order of the matrix A. */ |
| 58 |
/* N must be at least zero. */ |
| 59 |
/* Unchanged on exit. */ |
| 60 |
|
| 61 |
/* ALPHA - DOUBLE PRECISION. */ |
| 62 |
/* On entry, ALPHA specifies the scalar alpha. */ |
| 63 |
/* Unchanged on exit. */ |
| 64 |
|
| 65 |
/* X - COMPLEX*16 array of dimension at least */ |
| 66 |
/* ( 1 + ( n - 1 )*abs( INCX ) ). */ |
| 67 |
/* Before entry, the incremented array X must contain the n */ |
| 68 |
/* element vector x. */ |
| 69 |
/* Unchanged on exit. */ |
| 70 |
|
| 71 |
/* INCX - INTEGER. */ |
| 72 |
/* On entry, INCX specifies the increment for the elements of */ |
| 73 |
/* X. INCX must not be zero. */ |
| 74 |
/* Unchanged on exit. */ |
| 75 |
|
| 76 |
/* A - COMPLEX*16 array of DIMENSION ( LDA, n ). */ |
| 77 |
/* Before entry with UPLO = 'U' or 'u', the leading n by n */ |
| 78 |
/* upper triangular part of the array A must contain the upper */ |
| 79 |
/* triangular part of the hermitian matrix and the strictly */ |
| 80 |
/* lower triangular part of A is not referenced. On exit, the */ |
| 81 |
/* upper triangular part of the array A is overwritten by the */ |
| 82 |
/* upper triangular part of the updated matrix. */ |
| 83 |
/* Before entry with UPLO = 'L' or 'l', the leading n by n */ |
| 84 |
/* lower triangular part of the array A must contain the lower */ |
| 85 |
/* triangular part of the hermitian matrix and the strictly */ |
| 86 |
/* upper triangular part of A is not referenced. On exit, the */ |
| 87 |
/* lower triangular part of the array A is overwritten by the */ |
| 88 |
/* lower triangular part of the updated matrix. */ |
| 89 |
/* Note that the imaginary parts of the diagonal elements need */ |
| 90 |
/* not be set, they are assumed to be zero, and on exit they */ |
| 91 |
/* are set to zero. */ |
| 92 |
|
| 93 |
/* LDA - INTEGER. */ |
| 94 |
/* On entry, LDA specifies the first dimension of A as declared */ |
| 95 |
/* in the calling (sub) program. LDA must be at least */ |
| 96 |
/* max( 1, n ). */ |
| 97 |
/* Unchanged on exit. */ |
| 98 |
|
| 99 |
|
| 100 |
/* Level 2 Blas routine. */ |
| 101 |
|
| 102 |
/* -- Written on 22-October-1986. */ |
| 103 |
/* Jack Dongarra, Argonne National Lab. */ |
| 104 |
/* Jeremy Du Croz, Nag Central Office. */ |
| 105 |
/* Sven Hammarling, Nag Central Office. */ |
| 106 |
/* Richard Hanson, Sandia National Labs. */ |
| 107 |
|
| 108 |
|
| 109 |
/* .. Parameters .. */ |
| 110 |
/* .. Local Scalars .. */ |
| 111 |
/* .. External Functions .. */ |
| 112 |
/* .. External Subroutines .. */ |
| 113 |
/* .. Intrinsic Functions .. */ |
| 114 |
/* .. */ |
| 115 |
/* .. Executable Statements .. */ |
| 116 |
|
| 117 |
/* Test the input parameters. */ |
| 118 |
|
| 119 |
/* Parameter adjustments */ |
| 120 |
--x; |
| 121 |
a_dim1 = *lda; |
| 122 |
a_offset = 1 + a_dim1; |
| 123 |
a -= a_offset; |
| 124 |
|
| 125 |
/* Function Body */ |
| 126 |
info = 0; |
| 127 |
if (! lsame_(uplo, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(uplo, "L", ( |
| 128 |
ftnlen)1, (ftnlen)1)) { |
| 129 |
info = 1; |
| 130 |
} else if (*n < 0) { |
| 131 |
info = 2; |
| 132 |
} else if (*incx == 0) { |
| 133 |
info = 5; |
| 134 |
} else if (*lda < max(1,*n)) { |
| 135 |
info = 7; |
| 136 |
} |
| 137 |
if (info != 0) { |
| 138 |
xerbla_("ZHER ", &info, (ftnlen)6); |
| 139 |
return 0; |
| 140 |
} |
| 141 |
|
| 142 |
/* Quick return if possible. */ |
| 143 |
|
| 144 |
if (*n == 0 || *alpha == 0.) { |
| 145 |
return 0; |
| 146 |
} |
| 147 |
|
| 148 |
/* Set the start point in X if the increment is not unity. */ |
| 149 |
|
| 150 |
if (*incx <= 0) { |
| 151 |
kx = 1 - (*n - 1) * *incx; |
| 152 |
} else if (*incx != 1) { |
| 153 |
kx = 1; |
| 154 |
} |
| 155 |
|
| 156 |
/* Start the operations. In this version the elements of A are */ |
| 157 |
/* accessed sequentially with one pass through the triangular part */ |
| 158 |
/* of A. */ |
| 159 |
|
| 160 |
if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) { |
| 161 |
|
| 162 |
/* Form A when A is stored in upper triangle. */ |
| 163 |
|
| 164 |
if (*incx == 1) { |
| 165 |
i__1 = *n; |
| 166 |
for (j = 1; j <= i__1; ++j) { |
| 167 |
i__2 = j; |
| 168 |
if (x[i__2].r != 0. || x[i__2].i != 0.) { |
| 169 |
d_cnjg(&z__2, &x[j]); |
| 170 |
z__1.r = *alpha * z__2.r, z__1.i = *alpha * z__2.i; |
| 171 |
temp.r = z__1.r, temp.i = z__1.i; |
| 172 |
i__2 = j - 1; |
| 173 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 174 |
i__3 = i__ + j * a_dim1; |
| 175 |
i__4 = i__ + j * a_dim1; |
| 176 |
i__5 = i__; |
| 177 |
z__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i, |
| 178 |
z__2.i = x[i__5].r * temp.i + x[i__5].i * |
| 179 |
temp.r; |
| 180 |
z__1.r = a[i__4].r + z__2.r, z__1.i = a[i__4].i + |
| 181 |
z__2.i; |
| 182 |
a[i__3].r = z__1.r, a[i__3].i = z__1.i; |
| 183 |
/* L10: */ |
| 184 |
} |
| 185 |
i__2 = j + j * a_dim1; |
| 186 |
i__3 = j + j * a_dim1; |
| 187 |
i__4 = j; |
| 188 |
z__1.r = x[i__4].r * temp.r - x[i__4].i * temp.i, z__1.i = |
| 189 |
x[i__4].r * temp.i + x[i__4].i * temp.r; |
| 190 |
d__1 = a[i__3].r + z__1.r; |
| 191 |
a[i__2].r = d__1, a[i__2].i = 0.; |
| 192 |
} else { |
| 193 |
i__2 = j + j * a_dim1; |
| 194 |
i__3 = j + j * a_dim1; |
| 195 |
d__1 = a[i__3].r; |
| 196 |
a[i__2].r = d__1, a[i__2].i = 0.; |
| 197 |
} |
| 198 |
/* L20: */ |
| 199 |
} |
| 200 |
} else { |
| 201 |
jx = kx; |
| 202 |
i__1 = *n; |
| 203 |
for (j = 1; j <= i__1; ++j) { |
| 204 |
i__2 = jx; |
| 205 |
if (x[i__2].r != 0. || x[i__2].i != 0.) { |
| 206 |
d_cnjg(&z__2, &x[jx]); |
| 207 |
z__1.r = *alpha * z__2.r, z__1.i = *alpha * z__2.i; |
| 208 |
temp.r = z__1.r, temp.i = z__1.i; |
| 209 |
ix = kx; |
| 210 |
i__2 = j - 1; |
| 211 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 212 |
i__3 = i__ + j * a_dim1; |
| 213 |
i__4 = i__ + j * a_dim1; |
| 214 |
i__5 = ix; |
| 215 |
z__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i, |
| 216 |
z__2.i = x[i__5].r * temp.i + x[i__5].i * |
| 217 |
temp.r; |
| 218 |
z__1.r = a[i__4].r + z__2.r, z__1.i = a[i__4].i + |
| 219 |
z__2.i; |
| 220 |
a[i__3].r = z__1.r, a[i__3].i = z__1.i; |
| 221 |
ix += *incx; |
| 222 |
/* L30: */ |
| 223 |
} |
| 224 |
i__2 = j + j * a_dim1; |
| 225 |
i__3 = j + j * a_dim1; |
| 226 |
i__4 = jx; |
| 227 |
z__1.r = x[i__4].r * temp.r - x[i__4].i * temp.i, z__1.i = |
| 228 |
x[i__4].r * temp.i + x[i__4].i * temp.r; |
| 229 |
d__1 = a[i__3].r + z__1.r; |
| 230 |
a[i__2].r = d__1, a[i__2].i = 0.; |
| 231 |
} else { |
| 232 |
i__2 = j + j * a_dim1; |
| 233 |
i__3 = j + j * a_dim1; |
| 234 |
d__1 = a[i__3].r; |
| 235 |
a[i__2].r = d__1, a[i__2].i = 0.; |
| 236 |
} |
| 237 |
jx += *incx; |
| 238 |
/* L40: */ |
| 239 |
} |
| 240 |
} |
| 241 |
} else { |
| 242 |
|
| 243 |
/* Form A when A is stored in lower triangle. */ |
| 244 |
|
| 245 |
if (*incx == 1) { |
| 246 |
i__1 = *n; |
| 247 |
for (j = 1; j <= i__1; ++j) { |
| 248 |
i__2 = j; |
| 249 |
if (x[i__2].r != 0. || x[i__2].i != 0.) { |
| 250 |
d_cnjg(&z__2, &x[j]); |
| 251 |
z__1.r = *alpha * z__2.r, z__1.i = *alpha * z__2.i; |
| 252 |
temp.r = z__1.r, temp.i = z__1.i; |
| 253 |
i__2 = j + j * a_dim1; |
| 254 |
i__3 = j + j * a_dim1; |
| 255 |
i__4 = j; |
| 256 |
z__1.r = temp.r * x[i__4].r - temp.i * x[i__4].i, z__1.i = |
| 257 |
temp.r * x[i__4].i + temp.i * x[i__4].r; |
| 258 |
d__1 = a[i__3].r + z__1.r; |
| 259 |
a[i__2].r = d__1, a[i__2].i = 0.; |
| 260 |
i__2 = *n; |
| 261 |
for (i__ = j + 1; i__ <= i__2; ++i__) { |
| 262 |
i__3 = i__ + j * a_dim1; |
| 263 |
i__4 = i__ + j * a_dim1; |
| 264 |
i__5 = i__; |
| 265 |
z__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i, |
| 266 |
z__2.i = x[i__5].r * temp.i + x[i__5].i * |
| 267 |
temp.r; |
| 268 |
z__1.r = a[i__4].r + z__2.r, z__1.i = a[i__4].i + |
| 269 |
z__2.i; |
| 270 |
a[i__3].r = z__1.r, a[i__3].i = z__1.i; |
| 271 |
/* L50: */ |
| 272 |
} |
| 273 |
} else { |
| 274 |
i__2 = j + j * a_dim1; |
| 275 |
i__3 = j + j * a_dim1; |
| 276 |
d__1 = a[i__3].r; |
| 277 |
a[i__2].r = d__1, a[i__2].i = 0.; |
| 278 |
} |
| 279 |
/* L60: */ |
| 280 |
} |
| 281 |
} else { |
| 282 |
jx = kx; |
| 283 |
i__1 = *n; |
| 284 |
for (j = 1; j <= i__1; ++j) { |
| 285 |
i__2 = jx; |
| 286 |
if (x[i__2].r != 0. || x[i__2].i != 0.) { |
| 287 |
d_cnjg(&z__2, &x[jx]); |
| 288 |
z__1.r = *alpha * z__2.r, z__1.i = *alpha * z__2.i; |
| 289 |
temp.r = z__1.r, temp.i = z__1.i; |
| 290 |
i__2 = j + j * a_dim1; |
| 291 |
i__3 = j + j * a_dim1; |
| 292 |
i__4 = jx; |
| 293 |
z__1.r = temp.r * x[i__4].r - temp.i * x[i__4].i, z__1.i = |
| 294 |
temp.r * x[i__4].i + temp.i * x[i__4].r; |
| 295 |
d__1 = a[i__3].r + z__1.r; |
| 296 |
a[i__2].r = d__1, a[i__2].i = 0.; |
| 297 |
ix = jx; |
| 298 |
i__2 = *n; |
| 299 |
for (i__ = j + 1; i__ <= i__2; ++i__) { |
| 300 |
ix += *incx; |
| 301 |
i__3 = i__ + j * a_dim1; |
| 302 |
i__4 = i__ + j * a_dim1; |
| 303 |
i__5 = ix; |
| 304 |
z__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i, |
| 305 |
z__2.i = x[i__5].r * temp.i + x[i__5].i * |
| 306 |
temp.r; |
| 307 |
z__1.r = a[i__4].r + z__2.r, z__1.i = a[i__4].i + |
| 308 |
z__2.i; |
| 309 |
a[i__3].r = z__1.r, a[i__3].i = z__1.i; |
| 310 |
/* L70: */ |
| 311 |
} |
| 312 |
} else { |
| 313 |
i__2 = j + j * a_dim1; |
| 314 |
i__3 = j + j * a_dim1; |
| 315 |
d__1 = a[i__3].r; |
| 316 |
a[i__2].r = d__1, a[i__2].i = 0.; |
| 317 |
} |
| 318 |
jx += *incx; |
| 319 |
/* L80: */ |
| 320 |
} |
| 321 |
} |
| 322 |
} |
| 323 |
|
| 324 |
return 0; |
| 325 |
|
| 326 |
/* End of ZHER . */ |
| 327 |
|
| 328 |
} /* zher_ */ |
| 329 |
|