00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016 int cher2_(char *uplo, integer *n, complex *alpha, complex *
00017 x, integer *incx, complex *y, integer *incy, complex *a, integer *lda)
00018 {
00019
00020 integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5, i__6;
00021 real r__1;
00022 complex q__1, q__2, q__3, q__4;
00023
00024
00025 void r_cnjg(complex *, complex *);
00026
00027
00028 integer i__, j, ix, iy, jx, jy, kx, ky, info;
00029 complex temp1, temp2;
00030 extern logical lsame_(char *, char *);
00031 extern int xerbla_(char *, integer *);
00032
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 --x;
00143 --y;
00144 a_dim1 = *lda;
00145 a_offset = 1 + a_dim1;
00146 a -= a_offset;
00147
00148
00149 info = 0;
00150 if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
00151 info = 1;
00152 } else if (*n < 0) {
00153 info = 2;
00154 } else if (*incx == 0) {
00155 info = 5;
00156 } else if (*incy == 0) {
00157 info = 7;
00158 } else if (*lda < max(1,*n)) {
00159 info = 9;
00160 }
00161 if (info != 0) {
00162 xerbla_("CHER2 ", &info);
00163 return 0;
00164 }
00165
00166
00167
00168 if (*n == 0 || alpha->r == 0.f && alpha->i == 0.f) {
00169 return 0;
00170 }
00171
00172
00173
00174
00175 if (*incx != 1 || *incy != 1) {
00176 if (*incx > 0) {
00177 kx = 1;
00178 } else {
00179 kx = 1 - (*n - 1) * *incx;
00180 }
00181 if (*incy > 0) {
00182 ky = 1;
00183 } else {
00184 ky = 1 - (*n - 1) * *incy;
00185 }
00186 jx = kx;
00187 jy = ky;
00188 }
00189
00190
00191
00192
00193
00194 if (lsame_(uplo, "U")) {
00195
00196
00197
00198 if (*incx == 1 && *incy == 1) {
00199 i__1 = *n;
00200 for (j = 1; j <= i__1; ++j) {
00201 i__2 = j;
00202 i__3 = j;
00203 if (x[i__2].r != 0.f || x[i__2].i != 0.f || (y[i__3].r != 0.f
00204 || y[i__3].i != 0.f)) {
00205 r_cnjg(&q__2, &y[j]);
00206 q__1.r = alpha->r * q__2.r - alpha->i * q__2.i, q__1.i =
00207 alpha->r * q__2.i + alpha->i * q__2.r;
00208 temp1.r = q__1.r, temp1.i = q__1.i;
00209 i__2 = j;
00210 q__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
00211 q__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
00212 .r;
00213 r_cnjg(&q__1, &q__2);
00214 temp2.r = q__1.r, temp2.i = q__1.i;
00215 i__2 = j - 1;
00216 for (i__ = 1; i__ <= i__2; ++i__) {
00217 i__3 = i__ + j * a_dim1;
00218 i__4 = i__ + j * a_dim1;
00219 i__5 = i__;
00220 q__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i,
00221 q__3.i = x[i__5].r * temp1.i + x[i__5].i *
00222 temp1.r;
00223 q__2.r = a[i__4].r + q__3.r, q__2.i = a[i__4].i +
00224 q__3.i;
00225 i__6 = i__;
00226 q__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i,
00227 q__4.i = y[i__6].r * temp2.i + y[i__6].i *
00228 temp2.r;
00229 q__1.r = q__2.r + q__4.r, q__1.i = q__2.i + q__4.i;
00230 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
00231
00232 }
00233 i__2 = j + j * a_dim1;
00234 i__3 = j + j * a_dim1;
00235 i__4 = j;
00236 q__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i,
00237 q__2.i = x[i__4].r * temp1.i + x[i__4].i *
00238 temp1.r;
00239 i__5 = j;
00240 q__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i,
00241 q__3.i = y[i__5].r * temp2.i + y[i__5].i *
00242 temp2.r;
00243 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
00244 r__1 = a[i__3].r + q__1.r;
00245 a[i__2].r = r__1, a[i__2].i = 0.f;
00246 } else {
00247 i__2 = j + j * a_dim1;
00248 i__3 = j + j * a_dim1;
00249 r__1 = a[i__3].r;
00250 a[i__2].r = r__1, a[i__2].i = 0.f;
00251 }
00252
00253 }
00254 } else {
00255 i__1 = *n;
00256 for (j = 1; j <= i__1; ++j) {
00257 i__2 = jx;
00258 i__3 = jy;
00259 if (x[i__2].r != 0.f || x[i__2].i != 0.f || (y[i__3].r != 0.f
00260 || y[i__3].i != 0.f)) {
00261 r_cnjg(&q__2, &y[jy]);
00262 q__1.r = alpha->r * q__2.r - alpha->i * q__2.i, q__1.i =
00263 alpha->r * q__2.i + alpha->i * q__2.r;
00264 temp1.r = q__1.r, temp1.i = q__1.i;
00265 i__2 = jx;
00266 q__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
00267 q__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
00268 .r;
00269 r_cnjg(&q__1, &q__2);
00270 temp2.r = q__1.r, temp2.i = q__1.i;
00271 ix = kx;
00272 iy = ky;
00273 i__2 = j - 1;
00274 for (i__ = 1; i__ <= i__2; ++i__) {
00275 i__3 = i__ + j * a_dim1;
00276 i__4 = i__ + j * a_dim1;
00277 i__5 = ix;
00278 q__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i,
00279 q__3.i = x[i__5].r * temp1.i + x[i__5].i *
00280 temp1.r;
00281 q__2.r = a[i__4].r + q__3.r, q__2.i = a[i__4].i +
00282 q__3.i;
00283 i__6 = iy;
00284 q__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i,
00285 q__4.i = y[i__6].r * temp2.i + y[i__6].i *
00286 temp2.r;
00287 q__1.r = q__2.r + q__4.r, q__1.i = q__2.i + q__4.i;
00288 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
00289 ix += *incx;
00290 iy += *incy;
00291
00292 }
00293 i__2 = j + j * a_dim1;
00294 i__3 = j + j * a_dim1;
00295 i__4 = jx;
00296 q__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i,
00297 q__2.i = x[i__4].r * temp1.i + x[i__4].i *
00298 temp1.r;
00299 i__5 = jy;
00300 q__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i,
00301 q__3.i = y[i__5].r * temp2.i + y[i__5].i *
00302 temp2.r;
00303 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
00304 r__1 = a[i__3].r + q__1.r;
00305 a[i__2].r = r__1, a[i__2].i = 0.f;
00306 } else {
00307 i__2 = j + j * a_dim1;
00308 i__3 = j + j * a_dim1;
00309 r__1 = a[i__3].r;
00310 a[i__2].r = r__1, a[i__2].i = 0.f;
00311 }
00312 jx += *incx;
00313 jy += *incy;
00314
00315 }
00316 }
00317 } else {
00318
00319
00320
00321 if (*incx == 1 && *incy == 1) {
00322 i__1 = *n;
00323 for (j = 1; j <= i__1; ++j) {
00324 i__2 = j;
00325 i__3 = j;
00326 if (x[i__2].r != 0.f || x[i__2].i != 0.f || (y[i__3].r != 0.f
00327 || y[i__3].i != 0.f)) {
00328 r_cnjg(&q__2, &y[j]);
00329 q__1.r = alpha->r * q__2.r - alpha->i * q__2.i, q__1.i =
00330 alpha->r * q__2.i + alpha->i * q__2.r;
00331 temp1.r = q__1.r, temp1.i = q__1.i;
00332 i__2 = j;
00333 q__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
00334 q__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
00335 .r;
00336 r_cnjg(&q__1, &q__2);
00337 temp2.r = q__1.r, temp2.i = q__1.i;
00338 i__2 = j + j * a_dim1;
00339 i__3 = j + j * a_dim1;
00340 i__4 = j;
00341 q__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i,
00342 q__2.i = x[i__4].r * temp1.i + x[i__4].i *
00343 temp1.r;
00344 i__5 = j;
00345 q__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i,
00346 q__3.i = y[i__5].r * temp2.i + y[i__5].i *
00347 temp2.r;
00348 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
00349 r__1 = a[i__3].r + q__1.r;
00350 a[i__2].r = r__1, a[i__2].i = 0.f;
00351 i__2 = *n;
00352 for (i__ = j + 1; i__ <= i__2; ++i__) {
00353 i__3 = i__ + j * a_dim1;
00354 i__4 = i__ + j * a_dim1;
00355 i__5 = i__;
00356 q__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i,
00357 q__3.i = x[i__5].r * temp1.i + x[i__5].i *
00358 temp1.r;
00359 q__2.r = a[i__4].r + q__3.r, q__2.i = a[i__4].i +
00360 q__3.i;
00361 i__6 = i__;
00362 q__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i,
00363 q__4.i = y[i__6].r * temp2.i + y[i__6].i *
00364 temp2.r;
00365 q__1.r = q__2.r + q__4.r, q__1.i = q__2.i + q__4.i;
00366 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
00367
00368 }
00369 } else {
00370 i__2 = j + j * a_dim1;
00371 i__3 = j + j * a_dim1;
00372 r__1 = a[i__3].r;
00373 a[i__2].r = r__1, a[i__2].i = 0.f;
00374 }
00375
00376 }
00377 } else {
00378 i__1 = *n;
00379 for (j = 1; j <= i__1; ++j) {
00380 i__2 = jx;
00381 i__3 = jy;
00382 if (x[i__2].r != 0.f || x[i__2].i != 0.f || (y[i__3].r != 0.f
00383 || y[i__3].i != 0.f)) {
00384 r_cnjg(&q__2, &y[jy]);
00385 q__1.r = alpha->r * q__2.r - alpha->i * q__2.i, q__1.i =
00386 alpha->r * q__2.i + alpha->i * q__2.r;
00387 temp1.r = q__1.r, temp1.i = q__1.i;
00388 i__2 = jx;
00389 q__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
00390 q__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
00391 .r;
00392 r_cnjg(&q__1, &q__2);
00393 temp2.r = q__1.r, temp2.i = q__1.i;
00394 i__2 = j + j * a_dim1;
00395 i__3 = j + j * a_dim1;
00396 i__4 = jx;
00397 q__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i,
00398 q__2.i = x[i__4].r * temp1.i + x[i__4].i *
00399 temp1.r;
00400 i__5 = jy;
00401 q__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i,
00402 q__3.i = y[i__5].r * temp2.i + y[i__5].i *
00403 temp2.r;
00404 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
00405 r__1 = a[i__3].r + q__1.r;
00406 a[i__2].r = r__1, a[i__2].i = 0.f;
00407 ix = jx;
00408 iy = jy;
00409 i__2 = *n;
00410 for (i__ = j + 1; i__ <= i__2; ++i__) {
00411 ix += *incx;
00412 iy += *incy;
00413 i__3 = i__ + j * a_dim1;
00414 i__4 = i__ + j * a_dim1;
00415 i__5 = ix;
00416 q__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i,
00417 q__3.i = x[i__5].r * temp1.i + x[i__5].i *
00418 temp1.r;
00419 q__2.r = a[i__4].r + q__3.r, q__2.i = a[i__4].i +
00420 q__3.i;
00421 i__6 = iy;
00422 q__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i,
00423 q__4.i = y[i__6].r * temp2.i + y[i__6].i *
00424 temp2.r;
00425 q__1.r = q__2.r + q__4.r, q__1.i = q__2.i + q__4.i;
00426 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
00427
00428 }
00429 } else {
00430 i__2 = j + j * a_dim1;
00431 i__3 = j + j * a_dim1;
00432 r__1 = a[i__3].r;
00433 a[i__2].r = r__1, a[i__2].i = 0.f;
00434 }
00435 jx += *incx;
00436 jy += *incy;
00437
00438 }
00439 }
00440 }
00441
00442 return 0;
00443
00444
00445
00446 }