00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016 int zher2_(char *uplo, integer *n, doublecomplex *alpha,
00017 doublecomplex *x, integer *incx, doublecomplex *y, integer *incy,
00018 doublecomplex *a, integer *lda)
00019 {
00020
00021 integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5, i__6;
00022 doublereal d__1;
00023 doublecomplex z__1, z__2, z__3, z__4;
00024
00025
00026 void d_cnjg(doublecomplex *, doublecomplex *);
00027
00028
00029 integer i__, j, ix, iy, jx, jy, kx, ky, info;
00030 doublecomplex temp1, temp2;
00031 extern logical lsame_(char *, char *);
00032 extern int xerbla_(char *, integer *);
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143 --x;
00144 --y;
00145 a_dim1 = *lda;
00146 a_offset = 1 + a_dim1;
00147 a -= a_offset;
00148
00149
00150 info = 0;
00151 if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
00152 info = 1;
00153 } else if (*n < 0) {
00154 info = 2;
00155 } else if (*incx == 0) {
00156 info = 5;
00157 } else if (*incy == 0) {
00158 info = 7;
00159 } else if (*lda < max(1,*n)) {
00160 info = 9;
00161 }
00162 if (info != 0) {
00163 xerbla_("ZHER2 ", &info);
00164 return 0;
00165 }
00166
00167
00168
00169 if (*n == 0 || alpha->r == 0. && alpha->i == 0.) {
00170 return 0;
00171 }
00172
00173
00174
00175
00176 if (*incx != 1 || *incy != 1) {
00177 if (*incx > 0) {
00178 kx = 1;
00179 } else {
00180 kx = 1 - (*n - 1) * *incx;
00181 }
00182 if (*incy > 0) {
00183 ky = 1;
00184 } else {
00185 ky = 1 - (*n - 1) * *incy;
00186 }
00187 jx = kx;
00188 jy = ky;
00189 }
00190
00191
00192
00193
00194
00195 if (lsame_(uplo, "U")) {
00196
00197
00198
00199 if (*incx == 1 && *incy == 1) {
00200 i__1 = *n;
00201 for (j = 1; j <= i__1; ++j) {
00202 i__2 = j;
00203 i__3 = j;
00204 if (x[i__2].r != 0. || x[i__2].i != 0. || (y[i__3].r != 0. ||
00205 y[i__3].i != 0.)) {
00206 d_cnjg(&z__2, &y[j]);
00207 z__1.r = alpha->r * z__2.r - alpha->i * z__2.i, z__1.i =
00208 alpha->r * z__2.i + alpha->i * z__2.r;
00209 temp1.r = z__1.r, temp1.i = z__1.i;
00210 i__2 = j;
00211 z__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
00212 z__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
00213 .r;
00214 d_cnjg(&z__1, &z__2);
00215 temp2.r = z__1.r, temp2.i = z__1.i;
00216 i__2 = j - 1;
00217 for (i__ = 1; i__ <= i__2; ++i__) {
00218 i__3 = i__ + j * a_dim1;
00219 i__4 = i__ + j * a_dim1;
00220 i__5 = i__;
00221 z__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i,
00222 z__3.i = x[i__5].r * temp1.i + x[i__5].i *
00223 temp1.r;
00224 z__2.r = a[i__4].r + z__3.r, z__2.i = a[i__4].i +
00225 z__3.i;
00226 i__6 = i__;
00227 z__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i,
00228 z__4.i = y[i__6].r * temp2.i + y[i__6].i *
00229 temp2.r;
00230 z__1.r = z__2.r + z__4.r, z__1.i = z__2.i + z__4.i;
00231 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
00232
00233 }
00234 i__2 = j + j * a_dim1;
00235 i__3 = j + j * a_dim1;
00236 i__4 = j;
00237 z__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i,
00238 z__2.i = x[i__4].r * temp1.i + x[i__4].i *
00239 temp1.r;
00240 i__5 = j;
00241 z__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i,
00242 z__3.i = y[i__5].r * temp2.i + y[i__5].i *
00243 temp2.r;
00244 z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00245 d__1 = a[i__3].r + z__1.r;
00246 a[i__2].r = d__1, a[i__2].i = 0.;
00247 } else {
00248 i__2 = j + j * a_dim1;
00249 i__3 = j + j * a_dim1;
00250 d__1 = a[i__3].r;
00251 a[i__2].r = d__1, a[i__2].i = 0.;
00252 }
00253
00254 }
00255 } else {
00256 i__1 = *n;
00257 for (j = 1; j <= i__1; ++j) {
00258 i__2 = jx;
00259 i__3 = jy;
00260 if (x[i__2].r != 0. || x[i__2].i != 0. || (y[i__3].r != 0. ||
00261 y[i__3].i != 0.)) {
00262 d_cnjg(&z__2, &y[jy]);
00263 z__1.r = alpha->r * z__2.r - alpha->i * z__2.i, z__1.i =
00264 alpha->r * z__2.i + alpha->i * z__2.r;
00265 temp1.r = z__1.r, temp1.i = z__1.i;
00266 i__2 = jx;
00267 z__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
00268 z__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
00269 .r;
00270 d_cnjg(&z__1, &z__2);
00271 temp2.r = z__1.r, temp2.i = z__1.i;
00272 ix = kx;
00273 iy = ky;
00274 i__2 = j - 1;
00275 for (i__ = 1; i__ <= i__2; ++i__) {
00276 i__3 = i__ + j * a_dim1;
00277 i__4 = i__ + j * a_dim1;
00278 i__5 = ix;
00279 z__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i,
00280 z__3.i = x[i__5].r * temp1.i + x[i__5].i *
00281 temp1.r;
00282 z__2.r = a[i__4].r + z__3.r, z__2.i = a[i__4].i +
00283 z__3.i;
00284 i__6 = iy;
00285 z__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i,
00286 z__4.i = y[i__6].r * temp2.i + y[i__6].i *
00287 temp2.r;
00288 z__1.r = z__2.r + z__4.r, z__1.i = z__2.i + z__4.i;
00289 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
00290 ix += *incx;
00291 iy += *incy;
00292
00293 }
00294 i__2 = j + j * a_dim1;
00295 i__3 = j + j * a_dim1;
00296 i__4 = jx;
00297 z__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i,
00298 z__2.i = x[i__4].r * temp1.i + x[i__4].i *
00299 temp1.r;
00300 i__5 = jy;
00301 z__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i,
00302 z__3.i = y[i__5].r * temp2.i + y[i__5].i *
00303 temp2.r;
00304 z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00305 d__1 = a[i__3].r + z__1.r;
00306 a[i__2].r = d__1, a[i__2].i = 0.;
00307 } else {
00308 i__2 = j + j * a_dim1;
00309 i__3 = j + j * a_dim1;
00310 d__1 = a[i__3].r;
00311 a[i__2].r = d__1, a[i__2].i = 0.;
00312 }
00313 jx += *incx;
00314 jy += *incy;
00315
00316 }
00317 }
00318 } else {
00319
00320
00321
00322 if (*incx == 1 && *incy == 1) {
00323 i__1 = *n;
00324 for (j = 1; j <= i__1; ++j) {
00325 i__2 = j;
00326 i__3 = j;
00327 if (x[i__2].r != 0. || x[i__2].i != 0. || (y[i__3].r != 0. ||
00328 y[i__3].i != 0.)) {
00329 d_cnjg(&z__2, &y[j]);
00330 z__1.r = alpha->r * z__2.r - alpha->i * z__2.i, z__1.i =
00331 alpha->r * z__2.i + alpha->i * z__2.r;
00332 temp1.r = z__1.r, temp1.i = z__1.i;
00333 i__2 = j;
00334 z__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
00335 z__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
00336 .r;
00337 d_cnjg(&z__1, &z__2);
00338 temp2.r = z__1.r, temp2.i = z__1.i;
00339 i__2 = j + j * a_dim1;
00340 i__3 = j + j * a_dim1;
00341 i__4 = j;
00342 z__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i,
00343 z__2.i = x[i__4].r * temp1.i + x[i__4].i *
00344 temp1.r;
00345 i__5 = j;
00346 z__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i,
00347 z__3.i = y[i__5].r * temp2.i + y[i__5].i *
00348 temp2.r;
00349 z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00350 d__1 = a[i__3].r + z__1.r;
00351 a[i__2].r = d__1, a[i__2].i = 0.;
00352 i__2 = *n;
00353 for (i__ = j + 1; i__ <= i__2; ++i__) {
00354 i__3 = i__ + j * a_dim1;
00355 i__4 = i__ + j * a_dim1;
00356 i__5 = i__;
00357 z__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i,
00358 z__3.i = x[i__5].r * temp1.i + x[i__5].i *
00359 temp1.r;
00360 z__2.r = a[i__4].r + z__3.r, z__2.i = a[i__4].i +
00361 z__3.i;
00362 i__6 = i__;
00363 z__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i,
00364 z__4.i = y[i__6].r * temp2.i + y[i__6].i *
00365 temp2.r;
00366 z__1.r = z__2.r + z__4.r, z__1.i = z__2.i + z__4.i;
00367 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
00368
00369 }
00370 } else {
00371 i__2 = j + j * a_dim1;
00372 i__3 = j + j * a_dim1;
00373 d__1 = a[i__3].r;
00374 a[i__2].r = d__1, a[i__2].i = 0.;
00375 }
00376
00377 }
00378 } else {
00379 i__1 = *n;
00380 for (j = 1; j <= i__1; ++j) {
00381 i__2 = jx;
00382 i__3 = jy;
00383 if (x[i__2].r != 0. || x[i__2].i != 0. || (y[i__3].r != 0. ||
00384 y[i__3].i != 0.)) {
00385 d_cnjg(&z__2, &y[jy]);
00386 z__1.r = alpha->r * z__2.r - alpha->i * z__2.i, z__1.i =
00387 alpha->r * z__2.i + alpha->i * z__2.r;
00388 temp1.r = z__1.r, temp1.i = z__1.i;
00389 i__2 = jx;
00390 z__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
00391 z__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
00392 .r;
00393 d_cnjg(&z__1, &z__2);
00394 temp2.r = z__1.r, temp2.i = z__1.i;
00395 i__2 = j + j * a_dim1;
00396 i__3 = j + j * a_dim1;
00397 i__4 = jx;
00398 z__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i,
00399 z__2.i = x[i__4].r * temp1.i + x[i__4].i *
00400 temp1.r;
00401 i__5 = jy;
00402 z__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i,
00403 z__3.i = y[i__5].r * temp2.i + y[i__5].i *
00404 temp2.r;
00405 z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00406 d__1 = a[i__3].r + z__1.r;
00407 a[i__2].r = d__1, a[i__2].i = 0.;
00408 ix = jx;
00409 iy = jy;
00410 i__2 = *n;
00411 for (i__ = j + 1; i__ <= i__2; ++i__) {
00412 ix += *incx;
00413 iy += *incy;
00414 i__3 = i__ + j * a_dim1;
00415 i__4 = i__ + j * a_dim1;
00416 i__5 = ix;
00417 z__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i,
00418 z__3.i = x[i__5].r * temp1.i + x[i__5].i *
00419 temp1.r;
00420 z__2.r = a[i__4].r + z__3.r, z__2.i = a[i__4].i +
00421 z__3.i;
00422 i__6 = iy;
00423 z__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i,
00424 z__4.i = y[i__6].r * temp2.i + y[i__6].i *
00425 temp2.r;
00426 z__1.r = z__2.r + z__4.r, z__1.i = z__2.i + z__4.i;
00427 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
00428
00429 }
00430 } else {
00431 i__2 = j + j * a_dim1;
00432 i__3 = j + j * a_dim1;
00433 d__1 = a[i__3].r;
00434 a[i__2].r = d__1, a[i__2].i = 0.;
00435 }
00436 jx += *incx;
00437 jy += *incy;
00438
00439 }
00440 }
00441 }
00442
00443 return 0;
00444
00445
00446
00447 }