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