| 1 |
/* ./src_f77/zher2.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 zher2_(char *uplo, integer *n, doublecomplex *alpha, |
| 9 |
doublecomplex *x, integer *incx, doublecomplex *y, integer *incy, |
| 10 |
doublecomplex *a, integer *lda, ftnlen uplo_len) |
| 11 |
{ |
| 12 |
/* System generated locals */ |
| 13 |
integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5, i__6; |
| 14 |
doublereal d__1; |
| 15 |
doublecomplex z__1, z__2, z__3, z__4; |
| 16 |
|
| 17 |
/* Builtin functions */ |
| 18 |
void d_cnjg(doublecomplex *, doublecomplex *); |
| 19 |
|
| 20 |
/* Local variables */ |
| 21 |
static integer i__, j, ix, iy, jx, jy, kx, ky, info; |
| 22 |
static doublecomplex temp1, temp2; |
| 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 |
/* ZHER2 performs the hermitian rank 2 operation */ |
| 34 |
|
| 35 |
/* A := alpha*x*conjg( y' ) + conjg( alpha )*y*conjg( x' ) + A, */ |
| 36 |
|
| 37 |
/* where alpha is a scalar, x and y are n element vectors and A is an n */ |
| 38 |
/* 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 - COMPLEX*16 . */ |
| 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 |
/* Y - COMPLEX*16 array of dimension at least */ |
| 77 |
/* ( 1 + ( n - 1 )*abs( INCY ) ). */ |
| 78 |
/* Before entry, the incremented array Y must contain the n */ |
| 79 |
/* element vector y. */ |
| 80 |
/* Unchanged on exit. */ |
| 81 |
|
| 82 |
/* INCY - INTEGER. */ |
| 83 |
/* On entry, INCY specifies the increment for the elements of */ |
| 84 |
/* Y. INCY must not be zero. */ |
| 85 |
/* Unchanged on exit. */ |
| 86 |
|
| 87 |
/* A - COMPLEX*16 array of DIMENSION ( LDA, n ). */ |
| 88 |
/* Before entry with UPLO = 'U' or 'u', the leading n by n */ |
| 89 |
/* upper triangular part of the array A must contain the upper */ |
| 90 |
/* triangular part of the hermitian matrix and the strictly */ |
| 91 |
/* lower triangular part of A is not referenced. On exit, the */ |
| 92 |
/* upper triangular part of the array A is overwritten by the */ |
| 93 |
/* upper triangular part of the updated matrix. */ |
| 94 |
/* Before entry with UPLO = 'L' or 'l', the leading n by n */ |
| 95 |
/* lower triangular part of the array A must contain the lower */ |
| 96 |
/* triangular part of the hermitian matrix and the strictly */ |
| 97 |
/* upper triangular part of A is not referenced. On exit, the */ |
| 98 |
/* lower triangular part of the array A is overwritten by the */ |
| 99 |
/* lower triangular part of the updated matrix. */ |
| 100 |
/* Note that the imaginary parts of the diagonal elements need */ |
| 101 |
/* not be set, they are assumed to be zero, and on exit they */ |
| 102 |
/* are set to zero. */ |
| 103 |
|
| 104 |
/* LDA - INTEGER. */ |
| 105 |
/* On entry, LDA specifies the first dimension of A as declared */ |
| 106 |
/* in the calling (sub) program. LDA must be at least */ |
| 107 |
/* max( 1, n ). */ |
| 108 |
/* Unchanged on exit. */ |
| 109 |
|
| 110 |
|
| 111 |
/* Level 2 Blas routine. */ |
| 112 |
|
| 113 |
/* -- Written on 22-October-1986. */ |
| 114 |
/* Jack Dongarra, Argonne National Lab. */ |
| 115 |
/* Jeremy Du Croz, Nag Central Office. */ |
| 116 |
/* Sven Hammarling, Nag Central Office. */ |
| 117 |
/* Richard Hanson, Sandia National Labs. */ |
| 118 |
|
| 119 |
|
| 120 |
/* .. Parameters .. */ |
| 121 |
/* .. Local Scalars .. */ |
| 122 |
/* .. External Functions .. */ |
| 123 |
/* .. External Subroutines .. */ |
| 124 |
/* .. Intrinsic Functions .. */ |
| 125 |
/* .. */ |
| 126 |
/* .. Executable Statements .. */ |
| 127 |
|
| 128 |
/* Test the input parameters. */ |
| 129 |
|
| 130 |
/* Parameter adjustments */ |
| 131 |
--x; |
| 132 |
--y; |
| 133 |
a_dim1 = *lda; |
| 134 |
a_offset = 1 + a_dim1; |
| 135 |
a -= a_offset; |
| 136 |
|
| 137 |
/* Function Body */ |
| 138 |
info = 0; |
| 139 |
if (! lsame_(uplo, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(uplo, "L", ( |
| 140 |
ftnlen)1, (ftnlen)1)) { |
| 141 |
info = 1; |
| 142 |
} else if (*n < 0) { |
| 143 |
info = 2; |
| 144 |
} else if (*incx == 0) { |
| 145 |
info = 5; |
| 146 |
} else if (*incy == 0) { |
| 147 |
info = 7; |
| 148 |
} else if (*lda < max(1,*n)) { |
| 149 |
info = 9; |
| 150 |
} |
| 151 |
if (info != 0) { |
| 152 |
xerbla_("ZHER2 ", &info, (ftnlen)6); |
| 153 |
return 0; |
| 154 |
} |
| 155 |
|
| 156 |
/* Quick return if possible. */ |
| 157 |
|
| 158 |
if (*n == 0 || alpha->r == 0. && alpha->i == 0.) { |
| 159 |
return 0; |
| 160 |
} |
| 161 |
|
| 162 |
/* Set up the start points in X and Y if the increments are not both */ |
| 163 |
/* unity. */ |
| 164 |
|
| 165 |
if (*incx != 1 || *incy != 1) { |
| 166 |
if (*incx > 0) { |
| 167 |
kx = 1; |
| 168 |
} else { |
| 169 |
kx = 1 - (*n - 1) * *incx; |
| 170 |
} |
| 171 |
if (*incy > 0) { |
| 172 |
ky = 1; |
| 173 |
} else { |
| 174 |
ky = 1 - (*n - 1) * *incy; |
| 175 |
} |
| 176 |
jx = kx; |
| 177 |
jy = ky; |
| 178 |
} |
| 179 |
|
| 180 |
/* Start the operations. In this version the elements of A are */ |
| 181 |
/* accessed sequentially with one pass through the triangular part */ |
| 182 |
/* of A. */ |
| 183 |
|
| 184 |
if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) { |
| 185 |
|
| 186 |
/* Form A when A is stored in the upper triangle. */ |
| 187 |
|
| 188 |
if (*incx == 1 && *incy == 1) { |
| 189 |
i__1 = *n; |
| 190 |
for (j = 1; j <= i__1; ++j) { |
| 191 |
i__2 = j; |
| 192 |
i__3 = j; |
| 193 |
if (x[i__2].r != 0. || x[i__2].i != 0. || (y[i__3].r != 0. || |
| 194 |
y[i__3].i != 0.)) { |
| 195 |
d_cnjg(&z__2, &y[j]); |
| 196 |
z__1.r = alpha->r * z__2.r - alpha->i * z__2.i, z__1.i = |
| 197 |
alpha->r * z__2.i + alpha->i * z__2.r; |
| 198 |
temp1.r = z__1.r, temp1.i = z__1.i; |
| 199 |
i__2 = j; |
| 200 |
z__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, |
| 201 |
z__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2] |
| 202 |
.r; |
| 203 |
d_cnjg(&z__1, &z__2); |
| 204 |
temp2.r = z__1.r, temp2.i = z__1.i; |
| 205 |
i__2 = j - 1; |
| 206 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 207 |
i__3 = i__ + j * a_dim1; |
| 208 |
i__4 = i__ + j * a_dim1; |
| 209 |
i__5 = i__; |
| 210 |
z__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i, |
| 211 |
z__3.i = x[i__5].r * temp1.i + x[i__5].i * |
| 212 |
temp1.r; |
| 213 |
z__2.r = a[i__4].r + z__3.r, z__2.i = a[i__4].i + |
| 214 |
z__3.i; |
| 215 |
i__6 = i__; |
| 216 |
z__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i, |
| 217 |
z__4.i = y[i__6].r * temp2.i + y[i__6].i * |
| 218 |
temp2.r; |
| 219 |
z__1.r = z__2.r + z__4.r, z__1.i = z__2.i + z__4.i; |
| 220 |
a[i__3].r = z__1.r, a[i__3].i = z__1.i; |
| 221 |
/* L10: */ |
| 222 |
} |
| 223 |
i__2 = j + j * a_dim1; |
| 224 |
i__3 = j + j * a_dim1; |
| 225 |
i__4 = j; |
| 226 |
z__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i, |
| 227 |
z__2.i = x[i__4].r * temp1.i + x[i__4].i * |
| 228 |
temp1.r; |
| 229 |
i__5 = j; |
| 230 |
z__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i, |
| 231 |
z__3.i = y[i__5].r * temp2.i + y[i__5].i * |
| 232 |
temp2.r; |
| 233 |
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i; |
| 234 |
d__1 = a[i__3].r + z__1.r; |
| 235 |
a[i__2].r = d__1, a[i__2].i = 0.; |
| 236 |
} else { |
| 237 |
i__2 = j + j * a_dim1; |
| 238 |
i__3 = j + j * a_dim1; |
| 239 |
d__1 = a[i__3].r; |
| 240 |
a[i__2].r = d__1, a[i__2].i = 0.; |
| 241 |
} |
| 242 |
/* L20: */ |
| 243 |
} |
| 244 |
} else { |
| 245 |
i__1 = *n; |
| 246 |
for (j = 1; j <= i__1; ++j) { |
| 247 |
i__2 = jx; |
| 248 |
i__3 = jy; |
| 249 |
if (x[i__2].r != 0. || x[i__2].i != 0. || (y[i__3].r != 0. || |
| 250 |
y[i__3].i != 0.)) { |
| 251 |
d_cnjg(&z__2, &y[jy]); |
| 252 |
z__1.r = alpha->r * z__2.r - alpha->i * z__2.i, z__1.i = |
| 253 |
alpha->r * z__2.i + alpha->i * z__2.r; |
| 254 |
temp1.r = z__1.r, temp1.i = z__1.i; |
| 255 |
i__2 = jx; |
| 256 |
z__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, |
| 257 |
z__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2] |
| 258 |
.r; |
| 259 |
d_cnjg(&z__1, &z__2); |
| 260 |
temp2.r = z__1.r, temp2.i = z__1.i; |
| 261 |
ix = kx; |
| 262 |
iy = ky; |
| 263 |
i__2 = j - 1; |
| 264 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 265 |
i__3 = i__ + j * a_dim1; |
| 266 |
i__4 = i__ + j * a_dim1; |
| 267 |
i__5 = ix; |
| 268 |
z__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i, |
| 269 |
z__3.i = x[i__5].r * temp1.i + x[i__5].i * |
| 270 |
temp1.r; |
| 271 |
z__2.r = a[i__4].r + z__3.r, z__2.i = a[i__4].i + |
| 272 |
z__3.i; |
| 273 |
i__6 = iy; |
| 274 |
z__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i, |
| 275 |
z__4.i = y[i__6].r * temp2.i + y[i__6].i * |
| 276 |
temp2.r; |
| 277 |
z__1.r = z__2.r + z__4.r, z__1.i = z__2.i + z__4.i; |
| 278 |
a[i__3].r = z__1.r, a[i__3].i = z__1.i; |
| 279 |
ix += *incx; |
| 280 |
iy += *incy; |
| 281 |
/* L30: */ |
| 282 |
} |
| 283 |
i__2 = j + j * a_dim1; |
| 284 |
i__3 = j + j * a_dim1; |
| 285 |
i__4 = jx; |
| 286 |
z__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i, |
| 287 |
z__2.i = x[i__4].r * temp1.i + x[i__4].i * |
| 288 |
temp1.r; |
| 289 |
i__5 = jy; |
| 290 |
z__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i, |
| 291 |
z__3.i = y[i__5].r * temp2.i + y[i__5].i * |
| 292 |
temp2.r; |
| 293 |
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i; |
| 294 |
d__1 = a[i__3].r + z__1.r; |
| 295 |
a[i__2].r = d__1, a[i__2].i = 0.; |
| 296 |
} else { |
| 297 |
i__2 = j + j * a_dim1; |
| 298 |
i__3 = j + j * a_dim1; |
| 299 |
d__1 = a[i__3].r; |
| 300 |
a[i__2].r = d__1, a[i__2].i = 0.; |
| 301 |
} |
| 302 |
jx += *incx; |
| 303 |
jy += *incy; |
| 304 |
/* L40: */ |
| 305 |
} |
| 306 |
} |
| 307 |
} else { |
| 308 |
|
| 309 |
/* Form A when A is stored in the lower triangle. */ |
| 310 |
|
| 311 |
if (*incx == 1 && *incy == 1) { |
| 312 |
i__1 = *n; |
| 313 |
for (j = 1; j <= i__1; ++j) { |
| 314 |
i__2 = j; |
| 315 |
i__3 = j; |
| 316 |
if (x[i__2].r != 0. || x[i__2].i != 0. || (y[i__3].r != 0. || |
| 317 |
y[i__3].i != 0.)) { |
| 318 |
d_cnjg(&z__2, &y[j]); |
| 319 |
z__1.r = alpha->r * z__2.r - alpha->i * z__2.i, z__1.i = |
| 320 |
alpha->r * z__2.i + alpha->i * z__2.r; |
| 321 |
temp1.r = z__1.r, temp1.i = z__1.i; |
| 322 |
i__2 = j; |
| 323 |
z__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, |
| 324 |
z__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2] |
| 325 |
.r; |
| 326 |
d_cnjg(&z__1, &z__2); |
| 327 |
temp2.r = z__1.r, temp2.i = z__1.i; |
| 328 |
i__2 = j + j * a_dim1; |
| 329 |
i__3 = j + j * a_dim1; |
| 330 |
i__4 = j; |
| 331 |
z__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i, |
| 332 |
z__2.i = x[i__4].r * temp1.i + x[i__4].i * |
| 333 |
temp1.r; |
| 334 |
i__5 = j; |
| 335 |
z__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i, |
| 336 |
z__3.i = y[i__5].r * temp2.i + y[i__5].i * |
| 337 |
temp2.r; |
| 338 |
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i; |
| 339 |
d__1 = a[i__3].r + z__1.r; |
| 340 |
a[i__2].r = d__1, a[i__2].i = 0.; |
| 341 |
i__2 = *n; |
| 342 |
for (i__ = j + 1; i__ <= i__2; ++i__) { |
| 343 |
i__3 = i__ + j * a_dim1; |
| 344 |
i__4 = i__ + j * a_dim1; |
| 345 |
i__5 = i__; |
| 346 |
z__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i, |
| 347 |
z__3.i = x[i__5].r * temp1.i + x[i__5].i * |
| 348 |
temp1.r; |
| 349 |
z__2.r = a[i__4].r + z__3.r, z__2.i = a[i__4].i + |
| 350 |
z__3.i; |
| 351 |
i__6 = i__; |
| 352 |
z__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i, |
| 353 |
z__4.i = y[i__6].r * temp2.i + y[i__6].i * |
| 354 |
temp2.r; |
| 355 |
z__1.r = z__2.r + z__4.r, z__1.i = z__2.i + z__4.i; |
| 356 |
a[i__3].r = z__1.r, a[i__3].i = z__1.i; |
| 357 |
/* L50: */ |
| 358 |
} |
| 359 |
} else { |
| 360 |
i__2 = j + j * a_dim1; |
| 361 |
i__3 = j + j * a_dim1; |
| 362 |
d__1 = a[i__3].r; |
| 363 |
a[i__2].r = d__1, a[i__2].i = 0.; |
| 364 |
} |
| 365 |
/* L60: */ |
| 366 |
} |
| 367 |
} else { |
| 368 |
i__1 = *n; |
| 369 |
for (j = 1; j <= i__1; ++j) { |
| 370 |
i__2 = jx; |
| 371 |
i__3 = jy; |
| 372 |
if (x[i__2].r != 0. || x[i__2].i != 0. || (y[i__3].r != 0. || |
| 373 |
y[i__3].i != 0.)) { |
| 374 |
d_cnjg(&z__2, &y[jy]); |
| 375 |
z__1.r = alpha->r * z__2.r - alpha->i * z__2.i, z__1.i = |
| 376 |
alpha->r * z__2.i + alpha->i * z__2.r; |
| 377 |
temp1.r = z__1.r, temp1.i = z__1.i; |
| 378 |
i__2 = jx; |
| 379 |
z__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, |
| 380 |
z__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2] |
| 381 |
.r; |
| 382 |
d_cnjg(&z__1, &z__2); |
| 383 |
temp2.r = z__1.r, temp2.i = z__1.i; |
| 384 |
i__2 = j + j * a_dim1; |
| 385 |
i__3 = j + j * a_dim1; |
| 386 |
i__4 = jx; |
| 387 |
z__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i, |
| 388 |
z__2.i = x[i__4].r * temp1.i + x[i__4].i * |
| 389 |
temp1.r; |
| 390 |
i__5 = jy; |
| 391 |
z__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i, |
| 392 |
z__3.i = y[i__5].r * temp2.i + y[i__5].i * |
| 393 |
temp2.r; |
| 394 |
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i; |
| 395 |
d__1 = a[i__3].r + z__1.r; |
| 396 |
a[i__2].r = d__1, a[i__2].i = 0.; |
| 397 |
ix = jx; |
| 398 |
iy = jy; |
| 399 |
i__2 = *n; |
| 400 |
for (i__ = j + 1; i__ <= i__2; ++i__) { |
| 401 |
ix += *incx; |
| 402 |
iy += *incy; |
| 403 |
i__3 = i__ + j * a_dim1; |
| 404 |
i__4 = i__ + j * a_dim1; |
| 405 |
i__5 = ix; |
| 406 |
z__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i, |
| 407 |
z__3.i = x[i__5].r * temp1.i + x[i__5].i * |
| 408 |
temp1.r; |
| 409 |
z__2.r = a[i__4].r + z__3.r, z__2.i = a[i__4].i + |
| 410 |
z__3.i; |
| 411 |
i__6 = iy; |
| 412 |
z__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i, |
| 413 |
z__4.i = y[i__6].r * temp2.i + y[i__6].i * |
| 414 |
temp2.r; |
| 415 |
z__1.r = z__2.r + z__4.r, z__1.i = z__2.i + z__4.i; |
| 416 |
a[i__3].r = z__1.r, a[i__3].i = z__1.i; |
| 417 |
/* L70: */ |
| 418 |
} |
| 419 |
} else { |
| 420 |
i__2 = j + j * a_dim1; |
| 421 |
i__3 = j + j * a_dim1; |
| 422 |
d__1 = a[i__3].r; |
| 423 |
a[i__2].r = d__1, a[i__2].i = 0.; |
| 424 |
} |
| 425 |
jx += *incx; |
| 426 |
jy += *incy; |
| 427 |
/* L80: */ |
| 428 |
} |
| 429 |
} |
| 430 |
} |
| 431 |
|
| 432 |
return 0; |
| 433 |
|
| 434 |
/* End of ZHER2 . */ |
| 435 |
|
| 436 |
} /* zher2_ */ |
| 437 |
|