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