zhpr2.c
Go to the documentation of this file.
00001 /* zhpr2.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Subroutine */ int zhpr2_(char *uplo, integer *n, doublecomplex *alpha, 
00017         doublecomplex *x, integer *incx, doublecomplex *y, integer *incy, 
00018         doublecomplex *ap)
00019 {
00020     /* System generated locals */
00021     integer 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     /* Builtin functions */
00026     void d_cnjg(doublecomplex *, doublecomplex *);
00027 
00028     /* Local variables */
00029     integer i__, j, k, kk, ix, iy, jx, jy, kx, ky, info;
00030     doublecomplex temp1, temp2;
00031     extern logical lsame_(char *, char *);
00032     extern /* Subroutine */ int xerbla_(char *, integer *);
00033 
00034 /*     .. Scalar Arguments .. */
00035 /*     .. */
00036 /*     .. Array Arguments .. */
00037 /*     .. */
00038 
00039 /*  Purpose */
00040 /*  ======= */
00041 
00042 /*  ZHPR2  performs the hermitian rank 2 operation */
00043 
00044 /*     A := alpha*x*conjg( y' ) + conjg( alpha )*y*conjg( x' ) + A, */
00045 
00046 /*  where alpha is a scalar, x and y are n element vectors and A is an */
00047 /*  n by n hermitian matrix, supplied in packed form. */
00048 
00049 /*  Arguments */
00050 /*  ========== */
00051 
00052 /*  UPLO   - CHARACTER*1. */
00053 /*           On entry, UPLO specifies whether the upper or lower */
00054 /*           triangular part of the matrix A is supplied in the packed */
00055 /*           array AP as follows: */
00056 
00057 /*              UPLO = 'U' or 'u'   The upper triangular part of A is */
00058 /*                                  supplied in AP. */
00059 
00060 /*              UPLO = 'L' or 'l'   The lower triangular part of A is */
00061 /*                                  supplied in AP. */
00062 
00063 /*           Unchanged on exit. */
00064 
00065 /*  N      - INTEGER. */
00066 /*           On entry, N specifies the order of the matrix A. */
00067 /*           N must be at least zero. */
00068 /*           Unchanged on exit. */
00069 
00070 /*  ALPHA  - COMPLEX*16      . */
00071 /*           On entry, ALPHA specifies the scalar alpha. */
00072 /*           Unchanged on exit. */
00073 
00074 /*  X      - COMPLEX*16       array of dimension at least */
00075 /*           ( 1 + ( n - 1 )*abs( INCX ) ). */
00076 /*           Before entry, the incremented array X must contain the n */
00077 /*           element vector x. */
00078 /*           Unchanged on exit. */
00079 
00080 /*  INCX   - INTEGER. */
00081 /*           On entry, INCX specifies the increment for the elements of */
00082 /*           X. INCX must not be zero. */
00083 /*           Unchanged on exit. */
00084 
00085 /*  Y      - COMPLEX*16       array of dimension at least */
00086 /*           ( 1 + ( n - 1 )*abs( INCY ) ). */
00087 /*           Before entry, the incremented array Y must contain the n */
00088 /*           element vector y. */
00089 /*           Unchanged on exit. */
00090 
00091 /*  INCY   - INTEGER. */
00092 /*           On entry, INCY specifies the increment for the elements of */
00093 /*           Y. INCY must not be zero. */
00094 /*           Unchanged on exit. */
00095 
00096 /*  AP     - COMPLEX*16       array of DIMENSION at least */
00097 /*           ( ( n*( n + 1 ) )/2 ). */
00098 /*           Before entry with  UPLO = 'U' or 'u', the array AP must */
00099 /*           contain the upper triangular part of the hermitian matrix */
00100 /*           packed sequentially, column by column, so that AP( 1 ) */
00101 /*           contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 1, 2 ) */
00102 /*           and a( 2, 2 ) respectively, and so on. On exit, the array */
00103 /*           AP is overwritten by the upper triangular part of the */
00104 /*           updated matrix. */
00105 /*           Before entry with UPLO = 'L' or 'l', the array AP must */
00106 /*           contain the lower triangular part of the hermitian matrix */
00107 /*           packed sequentially, column by column, so that AP( 1 ) */
00108 /*           contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 2, 1 ) */
00109 /*           and a( 3, 1 ) respectively, and so on. On exit, the array */
00110 /*           AP is overwritten by the lower triangular part of the */
00111 /*           updated matrix. */
00112 /*           Note that the imaginary parts of the diagonal elements need */
00113 /*           not be set, they are assumed to be zero, and on exit they */
00114 /*           are set to zero. */
00115 
00116 
00117 /*  Level 2 Blas routine. */
00118 
00119 /*  -- Written on 22-October-1986. */
00120 /*     Jack Dongarra, Argonne National Lab. */
00121 /*     Jeremy Du Croz, Nag Central Office. */
00122 /*     Sven Hammarling, Nag Central Office. */
00123 /*     Richard Hanson, Sandia National Labs. */
00124 
00125 
00126 /*     .. Parameters .. */
00127 /*     .. */
00128 /*     .. Local Scalars .. */
00129 /*     .. */
00130 /*     .. External Functions .. */
00131 /*     .. */
00132 /*     .. External Subroutines .. */
00133 /*     .. */
00134 /*     .. Intrinsic Functions .. */
00135 /*     .. */
00136 
00137 /*     Test the input parameters. */
00138 
00139     /* Parameter adjustments */
00140     --ap;
00141     --y;
00142     --x;
00143 
00144     /* Function Body */
00145     info = 0;
00146     if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
00147         info = 1;
00148     } else if (*n < 0) {
00149         info = 2;
00150     } else if (*incx == 0) {
00151         info = 5;
00152     } else if (*incy == 0) {
00153         info = 7;
00154     }
00155     if (info != 0) {
00156         xerbla_("ZHPR2 ", &info);
00157         return 0;
00158     }
00159 
00160 /*     Quick return if possible. */
00161 
00162     if (*n == 0 || alpha->r == 0. && alpha->i == 0.) {
00163         return 0;
00164     }
00165 
00166 /*     Set up the start points in X and Y if the increments are not both */
00167 /*     unity. */
00168 
00169     if (*incx != 1 || *incy != 1) {
00170         if (*incx > 0) {
00171             kx = 1;
00172         } else {
00173             kx = 1 - (*n - 1) * *incx;
00174         }
00175         if (*incy > 0) {
00176             ky = 1;
00177         } else {
00178             ky = 1 - (*n - 1) * *incy;
00179         }
00180         jx = kx;
00181         jy = ky;
00182     }
00183 
00184 /*     Start the operations. In this version the elements of the array AP */
00185 /*     are accessed sequentially with one pass through AP. */
00186 
00187     kk = 1;
00188     if (lsame_(uplo, "U")) {
00189 
00190 /*        Form  A  when upper triangle is stored in AP. */
00191 
00192         if (*incx == 1 && *incy == 1) {
00193             i__1 = *n;
00194             for (j = 1; j <= i__1; ++j) {
00195                 i__2 = j;
00196                 i__3 = j;
00197                 if (x[i__2].r != 0. || x[i__2].i != 0. || (y[i__3].r != 0. || 
00198                         y[i__3].i != 0.)) {
00199                     d_cnjg(&z__2, &y[j]);
00200                     z__1.r = alpha->r * z__2.r - alpha->i * z__2.i, z__1.i = 
00201                             alpha->r * z__2.i + alpha->i * z__2.r;
00202                     temp1.r = z__1.r, temp1.i = z__1.i;
00203                     i__2 = j;
00204                     z__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, 
00205                             z__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
00206                             .r;
00207                     d_cnjg(&z__1, &z__2);
00208                     temp2.r = z__1.r, temp2.i = z__1.i;
00209                     k = kk;
00210                     i__2 = j - 1;
00211                     for (i__ = 1; i__ <= i__2; ++i__) {
00212                         i__3 = k;
00213                         i__4 = k;
00214                         i__5 = i__;
00215                         z__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i, 
00216                                 z__3.i = x[i__5].r * temp1.i + x[i__5].i * 
00217                                 temp1.r;
00218                         z__2.r = ap[i__4].r + z__3.r, z__2.i = ap[i__4].i + 
00219                                 z__3.i;
00220                         i__6 = i__;
00221                         z__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i, 
00222                                 z__4.i = y[i__6].r * temp2.i + y[i__6].i * 
00223                                 temp2.r;
00224                         z__1.r = z__2.r + z__4.r, z__1.i = z__2.i + z__4.i;
00225                         ap[i__3].r = z__1.r, ap[i__3].i = z__1.i;
00226                         ++k;
00227 /* L10: */
00228                     }
00229                     i__2 = kk + j - 1;
00230                     i__3 = kk + j - 1;
00231                     i__4 = j;
00232                     z__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i, 
00233                             z__2.i = x[i__4].r * temp1.i + x[i__4].i * 
00234                             temp1.r;
00235                     i__5 = j;
00236                     z__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i, 
00237                             z__3.i = y[i__5].r * temp2.i + y[i__5].i * 
00238                             temp2.r;
00239                     z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00240                     d__1 = ap[i__3].r + z__1.r;
00241                     ap[i__2].r = d__1, ap[i__2].i = 0.;
00242                 } else {
00243                     i__2 = kk + j - 1;
00244                     i__3 = kk + j - 1;
00245                     d__1 = ap[i__3].r;
00246                     ap[i__2].r = d__1, ap[i__2].i = 0.;
00247                 }
00248                 kk += j;
00249 /* L20: */
00250             }
00251         } else {
00252             i__1 = *n;
00253             for (j = 1; j <= i__1; ++j) {
00254                 i__2 = jx;
00255                 i__3 = jy;
00256                 if (x[i__2].r != 0. || x[i__2].i != 0. || (y[i__3].r != 0. || 
00257                         y[i__3].i != 0.)) {
00258                     d_cnjg(&z__2, &y[jy]);
00259                     z__1.r = alpha->r * z__2.r - alpha->i * z__2.i, z__1.i = 
00260                             alpha->r * z__2.i + alpha->i * z__2.r;
00261                     temp1.r = z__1.r, temp1.i = z__1.i;
00262                     i__2 = jx;
00263                     z__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, 
00264                             z__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
00265                             .r;
00266                     d_cnjg(&z__1, &z__2);
00267                     temp2.r = z__1.r, temp2.i = z__1.i;
00268                     ix = kx;
00269                     iy = ky;
00270                     i__2 = kk + j - 2;
00271                     for (k = kk; k <= i__2; ++k) {
00272                         i__3 = k;
00273                         i__4 = k;
00274                         i__5 = ix;
00275                         z__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i, 
00276                                 z__3.i = x[i__5].r * temp1.i + x[i__5].i * 
00277                                 temp1.r;
00278                         z__2.r = ap[i__4].r + z__3.r, z__2.i = ap[i__4].i + 
00279                                 z__3.i;
00280                         i__6 = iy;
00281                         z__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i, 
00282                                 z__4.i = y[i__6].r * temp2.i + y[i__6].i * 
00283                                 temp2.r;
00284                         z__1.r = z__2.r + z__4.r, z__1.i = z__2.i + z__4.i;
00285                         ap[i__3].r = z__1.r, ap[i__3].i = z__1.i;
00286                         ix += *incx;
00287                         iy += *incy;
00288 /* L30: */
00289                     }
00290                     i__2 = kk + j - 1;
00291                     i__3 = kk + j - 1;
00292                     i__4 = jx;
00293                     z__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i, 
00294                             z__2.i = x[i__4].r * temp1.i + x[i__4].i * 
00295                             temp1.r;
00296                     i__5 = jy;
00297                     z__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i, 
00298                             z__3.i = y[i__5].r * temp2.i + y[i__5].i * 
00299                             temp2.r;
00300                     z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00301                     d__1 = ap[i__3].r + z__1.r;
00302                     ap[i__2].r = d__1, ap[i__2].i = 0.;
00303                 } else {
00304                     i__2 = kk + j - 1;
00305                     i__3 = kk + j - 1;
00306                     d__1 = ap[i__3].r;
00307                     ap[i__2].r = d__1, ap[i__2].i = 0.;
00308                 }
00309                 jx += *incx;
00310                 jy += *incy;
00311                 kk += j;
00312 /* L40: */
00313             }
00314         }
00315     } else {
00316 
00317 /*        Form  A  when lower triangle is stored in AP. */
00318 
00319         if (*incx == 1 && *incy == 1) {
00320             i__1 = *n;
00321             for (j = 1; j <= i__1; ++j) {
00322                 i__2 = j;
00323                 i__3 = j;
00324                 if (x[i__2].r != 0. || x[i__2].i != 0. || (y[i__3].r != 0. || 
00325                         y[i__3].i != 0.)) {
00326                     d_cnjg(&z__2, &y[j]);
00327                     z__1.r = alpha->r * z__2.r - alpha->i * z__2.i, z__1.i = 
00328                             alpha->r * z__2.i + alpha->i * z__2.r;
00329                     temp1.r = z__1.r, temp1.i = z__1.i;
00330                     i__2 = j;
00331                     z__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, 
00332                             z__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
00333                             .r;
00334                     d_cnjg(&z__1, &z__2);
00335                     temp2.r = z__1.r, temp2.i = z__1.i;
00336                     i__2 = kk;
00337                     i__3 = kk;
00338                     i__4 = j;
00339                     z__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i, 
00340                             z__2.i = x[i__4].r * temp1.i + x[i__4].i * 
00341                             temp1.r;
00342                     i__5 = j;
00343                     z__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i, 
00344                             z__3.i = y[i__5].r * temp2.i + y[i__5].i * 
00345                             temp2.r;
00346                     z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00347                     d__1 = ap[i__3].r + z__1.r;
00348                     ap[i__2].r = d__1, ap[i__2].i = 0.;
00349                     k = kk + 1;
00350                     i__2 = *n;
00351                     for (i__ = j + 1; i__ <= i__2; ++i__) {
00352                         i__3 = k;
00353                         i__4 = k;
00354                         i__5 = i__;
00355                         z__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i, 
00356                                 z__3.i = x[i__5].r * temp1.i + x[i__5].i * 
00357                                 temp1.r;
00358                         z__2.r = ap[i__4].r + z__3.r, z__2.i = ap[i__4].i + 
00359                                 z__3.i;
00360                         i__6 = i__;
00361                         z__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i, 
00362                                 z__4.i = y[i__6].r * temp2.i + y[i__6].i * 
00363                                 temp2.r;
00364                         z__1.r = z__2.r + z__4.r, z__1.i = z__2.i + z__4.i;
00365                         ap[i__3].r = z__1.r, ap[i__3].i = z__1.i;
00366                         ++k;
00367 /* L50: */
00368                     }
00369                 } else {
00370                     i__2 = kk;
00371                     i__3 = kk;
00372                     d__1 = ap[i__3].r;
00373                     ap[i__2].r = d__1, ap[i__2].i = 0.;
00374                 }
00375                 kk = kk + *n - j + 1;
00376 /* L60: */
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 = kk;
00396                     i__3 = kk;
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 = ap[i__3].r + z__1.r;
00407                     ap[i__2].r = d__1, ap[i__2].i = 0.;
00408                     ix = jx;
00409                     iy = jy;
00410                     i__2 = kk + *n - j;
00411                     for (k = kk + 1; k <= i__2; ++k) {
00412                         ix += *incx;
00413                         iy += *incy;
00414                         i__3 = k;
00415                         i__4 = k;
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 = ap[i__4].r + z__3.r, z__2.i = ap[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                         ap[i__3].r = z__1.r, ap[i__3].i = z__1.i;
00428 /* L70: */
00429                     }
00430                 } else {
00431                     i__2 = kk;
00432                     i__3 = kk;
00433                     d__1 = ap[i__3].r;
00434                     ap[i__2].r = d__1, ap[i__2].i = 0.;
00435                 }
00436                 jx += *incx;
00437                 jy += *incy;
00438                 kk = kk + *n - j + 1;
00439 /* L80: */
00440             }
00441         }
00442     }
00443 
00444     return 0;
00445 
00446 /*     End of ZHPR2 . */
00447 
00448 } /* zhpr2_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:39