chpmv.c
Go to the documentation of this file.
00001 /* chpmv.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 chpmv_(char *uplo, integer *n, complex *alpha, complex *
00017         ap, complex *x, integer *incx, complex *beta, complex *y, integer *
00018         incy)
00019 {
00020     /* System generated locals */
00021     integer i__1, i__2, i__3, i__4, i__5;
00022     real r__1;
00023     complex q__1, q__2, q__3, q__4;
00024 
00025     /* Builtin functions */
00026     void r_cnjg(complex *, complex *);
00027 
00028     /* Local variables */
00029     integer i__, j, k, kk, ix, iy, jx, jy, kx, ky, info;
00030     complex 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 /*  CHPMV  performs the matrix-vector operation */
00043 
00044 /*     y := alpha*A*x + beta*y, */
00045 
00046 /*  where alpha and beta are scalars, x and y are n element vectors and */
00047 /*  A is an 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         . */
00071 /*           On entry, ALPHA specifies the scalar alpha. */
00072 /*           Unchanged on exit. */
00073 
00074 /*  AP     - COMPLEX          array of DIMENSION at least */
00075 /*           ( ( n*( n + 1 ) )/2 ). */
00076 /*           Before entry with UPLO = 'U' or 'u', the array AP must */
00077 /*           contain the upper triangular part of the hermitian matrix */
00078 /*           packed sequentially, column by column, so that AP( 1 ) */
00079 /*           contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 1, 2 ) */
00080 /*           and a( 2, 2 ) respectively, and so on. */
00081 /*           Before entry with UPLO = 'L' or 'l', the array AP must */
00082 /*           contain the lower triangular part of the hermitian matrix */
00083 /*           packed sequentially, column by column, so that AP( 1 ) */
00084 /*           contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 2, 1 ) */
00085 /*           and a( 3, 1 ) respectively, and so on. */
00086 /*           Note that the imaginary parts of the diagonal elements need */
00087 /*           not be set and are assumed to be zero. */
00088 /*           Unchanged on exit. */
00089 
00090 /*  X      - COMPLEX          array of dimension at least */
00091 /*           ( 1 + ( n - 1 )*abs( INCX ) ). */
00092 /*           Before entry, the incremented array X must contain the n */
00093 /*           element vector x. */
00094 /*           Unchanged on exit. */
00095 
00096 /*  INCX   - INTEGER. */
00097 /*           On entry, INCX specifies the increment for the elements of */
00098 /*           X. INCX must not be zero. */
00099 /*           Unchanged on exit. */
00100 
00101 /*  BETA   - COMPLEX         . */
00102 /*           On entry, BETA specifies the scalar beta. When BETA is */
00103 /*           supplied as zero then Y need not be set on input. */
00104 /*           Unchanged on exit. */
00105 
00106 /*  Y      - COMPLEX          array of dimension at least */
00107 /*           ( 1 + ( n - 1 )*abs( INCY ) ). */
00108 /*           Before entry, the incremented array Y must contain the n */
00109 /*           element vector y. On exit, Y is overwritten by the updated */
00110 /*           vector y. */
00111 
00112 /*  INCY   - INTEGER. */
00113 /*           On entry, INCY specifies the increment for the elements of */
00114 /*           Y. INCY must not be zero. */
00115 /*           Unchanged on exit. */
00116 
00117 
00118 /*  Level 2 Blas routine. */
00119 
00120 /*  -- Written on 22-October-1986. */
00121 /*     Jack Dongarra, Argonne National Lab. */
00122 /*     Jeremy Du Croz, Nag Central Office. */
00123 /*     Sven Hammarling, Nag Central Office. */
00124 /*     Richard Hanson, Sandia National Labs. */
00125 
00126 
00127 /*     .. Parameters .. */
00128 /*     .. */
00129 /*     .. Local Scalars .. */
00130 /*     .. */
00131 /*     .. External Functions .. */
00132 /*     .. */
00133 /*     .. External Subroutines .. */
00134 /*     .. */
00135 /*     .. Intrinsic Functions .. */
00136 /*     .. */
00137 
00138 /*     Test the input parameters. */
00139 
00140     /* Parameter adjustments */
00141     --y;
00142     --x;
00143     --ap;
00144 
00145     /* Function Body */
00146     info = 0;
00147     if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
00148         info = 1;
00149     } else if (*n < 0) {
00150         info = 2;
00151     } else if (*incx == 0) {
00152         info = 6;
00153     } else if (*incy == 0) {
00154         info = 9;
00155     }
00156     if (info != 0) {
00157         xerbla_("CHPMV ", &info);
00158         return 0;
00159     }
00160 
00161 /*     Quick return if possible. */
00162 
00163     if (*n == 0 || alpha->r == 0.f && alpha->i == 0.f && (beta->r == 1.f && 
00164             beta->i == 0.f)) {
00165         return 0;
00166     }
00167 
00168 /*     Set up the start points in  X  and  Y. */
00169 
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 
00181 /*     Start the operations. In this version the elements of the array AP */
00182 /*     are accessed sequentially with one pass through AP. */
00183 
00184 /*     First form  y := beta*y. */
00185 
00186     if (beta->r != 1.f || beta->i != 0.f) {
00187         if (*incy == 1) {
00188             if (beta->r == 0.f && beta->i == 0.f) {
00189                 i__1 = *n;
00190                 for (i__ = 1; i__ <= i__1; ++i__) {
00191                     i__2 = i__;
00192                     y[i__2].r = 0.f, y[i__2].i = 0.f;
00193 /* L10: */
00194                 }
00195             } else {
00196                 i__1 = *n;
00197                 for (i__ = 1; i__ <= i__1; ++i__) {
00198                     i__2 = i__;
00199                     i__3 = i__;
00200                     q__1.r = beta->r * y[i__3].r - beta->i * y[i__3].i, 
00201                             q__1.i = beta->r * y[i__3].i + beta->i * y[i__3]
00202                             .r;
00203                     y[i__2].r = q__1.r, y[i__2].i = q__1.i;
00204 /* L20: */
00205                 }
00206             }
00207         } else {
00208             iy = ky;
00209             if (beta->r == 0.f && beta->i == 0.f) {
00210                 i__1 = *n;
00211                 for (i__ = 1; i__ <= i__1; ++i__) {
00212                     i__2 = iy;
00213                     y[i__2].r = 0.f, y[i__2].i = 0.f;
00214                     iy += *incy;
00215 /* L30: */
00216                 }
00217             } else {
00218                 i__1 = *n;
00219                 for (i__ = 1; i__ <= i__1; ++i__) {
00220                     i__2 = iy;
00221                     i__3 = iy;
00222                     q__1.r = beta->r * y[i__3].r - beta->i * y[i__3].i, 
00223                             q__1.i = beta->r * y[i__3].i + beta->i * y[i__3]
00224                             .r;
00225                     y[i__2].r = q__1.r, y[i__2].i = q__1.i;
00226                     iy += *incy;
00227 /* L40: */
00228                 }
00229             }
00230         }
00231     }
00232     if (alpha->r == 0.f && alpha->i == 0.f) {
00233         return 0;
00234     }
00235     kk = 1;
00236     if (lsame_(uplo, "U")) {
00237 
00238 /*        Form  y  when AP contains the upper triangle. */
00239 
00240         if (*incx == 1 && *incy == 1) {
00241             i__1 = *n;
00242             for (j = 1; j <= i__1; ++j) {
00243                 i__2 = j;
00244                 q__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, q__1.i =
00245                          alpha->r * x[i__2].i + alpha->i * x[i__2].r;
00246                 temp1.r = q__1.r, temp1.i = q__1.i;
00247                 temp2.r = 0.f, temp2.i = 0.f;
00248                 k = kk;
00249                 i__2 = j - 1;
00250                 for (i__ = 1; i__ <= i__2; ++i__) {
00251                     i__3 = i__;
00252                     i__4 = i__;
00253                     i__5 = k;
00254                     q__2.r = temp1.r * ap[i__5].r - temp1.i * ap[i__5].i, 
00255                             q__2.i = temp1.r * ap[i__5].i + temp1.i * ap[i__5]
00256                             .r;
00257                     q__1.r = y[i__4].r + q__2.r, q__1.i = y[i__4].i + q__2.i;
00258                     y[i__3].r = q__1.r, y[i__3].i = q__1.i;
00259                     r_cnjg(&q__3, &ap[k]);
00260                     i__3 = i__;
00261                     q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i, q__2.i =
00262                              q__3.r * x[i__3].i + q__3.i * x[i__3].r;
00263                     q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
00264                     temp2.r = q__1.r, temp2.i = q__1.i;
00265                     ++k;
00266 /* L50: */
00267                 }
00268                 i__2 = j;
00269                 i__3 = j;
00270                 i__4 = kk + j - 1;
00271                 r__1 = ap[i__4].r;
00272                 q__3.r = r__1 * temp1.r, q__3.i = r__1 * temp1.i;
00273                 q__2.r = y[i__3].r + q__3.r, q__2.i = y[i__3].i + q__3.i;
00274                 q__4.r = alpha->r * temp2.r - alpha->i * temp2.i, q__4.i = 
00275                         alpha->r * temp2.i + alpha->i * temp2.r;
00276                 q__1.r = q__2.r + q__4.r, q__1.i = q__2.i + q__4.i;
00277                 y[i__2].r = q__1.r, y[i__2].i = q__1.i;
00278                 kk += j;
00279 /* L60: */
00280             }
00281         } else {
00282             jx = kx;
00283             jy = ky;
00284             i__1 = *n;
00285             for (j = 1; j <= i__1; ++j) {
00286                 i__2 = jx;
00287                 q__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, q__1.i =
00288                          alpha->r * x[i__2].i + alpha->i * x[i__2].r;
00289                 temp1.r = q__1.r, temp1.i = q__1.i;
00290                 temp2.r = 0.f, temp2.i = 0.f;
00291                 ix = kx;
00292                 iy = ky;
00293                 i__2 = kk + j - 2;
00294                 for (k = kk; k <= i__2; ++k) {
00295                     i__3 = iy;
00296                     i__4 = iy;
00297                     i__5 = k;
00298                     q__2.r = temp1.r * ap[i__5].r - temp1.i * ap[i__5].i, 
00299                             q__2.i = temp1.r * ap[i__5].i + temp1.i * ap[i__5]
00300                             .r;
00301                     q__1.r = y[i__4].r + q__2.r, q__1.i = y[i__4].i + q__2.i;
00302                     y[i__3].r = q__1.r, y[i__3].i = q__1.i;
00303                     r_cnjg(&q__3, &ap[k]);
00304                     i__3 = ix;
00305                     q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i, q__2.i =
00306                              q__3.r * x[i__3].i + q__3.i * x[i__3].r;
00307                     q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
00308                     temp2.r = q__1.r, temp2.i = q__1.i;
00309                     ix += *incx;
00310                     iy += *incy;
00311 /* L70: */
00312                 }
00313                 i__2 = jy;
00314                 i__3 = jy;
00315                 i__4 = kk + j - 1;
00316                 r__1 = ap[i__4].r;
00317                 q__3.r = r__1 * temp1.r, q__3.i = r__1 * temp1.i;
00318                 q__2.r = y[i__3].r + q__3.r, q__2.i = y[i__3].i + q__3.i;
00319                 q__4.r = alpha->r * temp2.r - alpha->i * temp2.i, q__4.i = 
00320                         alpha->r * temp2.i + alpha->i * temp2.r;
00321                 q__1.r = q__2.r + q__4.r, q__1.i = q__2.i + q__4.i;
00322                 y[i__2].r = q__1.r, y[i__2].i = q__1.i;
00323                 jx += *incx;
00324                 jy += *incy;
00325                 kk += j;
00326 /* L80: */
00327             }
00328         }
00329     } else {
00330 
00331 /*        Form  y  when AP contains the lower triangle. */
00332 
00333         if (*incx == 1 && *incy == 1) {
00334             i__1 = *n;
00335             for (j = 1; j <= i__1; ++j) {
00336                 i__2 = j;
00337                 q__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, q__1.i =
00338                          alpha->r * x[i__2].i + alpha->i * x[i__2].r;
00339                 temp1.r = q__1.r, temp1.i = q__1.i;
00340                 temp2.r = 0.f, temp2.i = 0.f;
00341                 i__2 = j;
00342                 i__3 = j;
00343                 i__4 = kk;
00344                 r__1 = ap[i__4].r;
00345                 q__2.r = r__1 * temp1.r, q__2.i = r__1 * temp1.i;
00346                 q__1.r = y[i__3].r + q__2.r, q__1.i = y[i__3].i + q__2.i;
00347                 y[i__2].r = q__1.r, y[i__2].i = q__1.i;
00348                 k = kk + 1;
00349                 i__2 = *n;
00350                 for (i__ = j + 1; i__ <= i__2; ++i__) {
00351                     i__3 = i__;
00352                     i__4 = i__;
00353                     i__5 = k;
00354                     q__2.r = temp1.r * ap[i__5].r - temp1.i * ap[i__5].i, 
00355                             q__2.i = temp1.r * ap[i__5].i + temp1.i * ap[i__5]
00356                             .r;
00357                     q__1.r = y[i__4].r + q__2.r, q__1.i = y[i__4].i + q__2.i;
00358                     y[i__3].r = q__1.r, y[i__3].i = q__1.i;
00359                     r_cnjg(&q__3, &ap[k]);
00360                     i__3 = i__;
00361                     q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i, q__2.i =
00362                              q__3.r * x[i__3].i + q__3.i * x[i__3].r;
00363                     q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
00364                     temp2.r = q__1.r, temp2.i = q__1.i;
00365                     ++k;
00366 /* L90: */
00367                 }
00368                 i__2 = j;
00369                 i__3 = j;
00370                 q__2.r = alpha->r * temp2.r - alpha->i * temp2.i, q__2.i = 
00371                         alpha->r * temp2.i + alpha->i * temp2.r;
00372                 q__1.r = y[i__3].r + q__2.r, q__1.i = y[i__3].i + q__2.i;
00373                 y[i__2].r = q__1.r, y[i__2].i = q__1.i;
00374                 kk += *n - j + 1;
00375 /* L100: */
00376             }
00377         } else {
00378             jx = kx;
00379             jy = ky;
00380             i__1 = *n;
00381             for (j = 1; j <= i__1; ++j) {
00382                 i__2 = jx;
00383                 q__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, q__1.i =
00384                          alpha->r * x[i__2].i + alpha->i * x[i__2].r;
00385                 temp1.r = q__1.r, temp1.i = q__1.i;
00386                 temp2.r = 0.f, temp2.i = 0.f;
00387                 i__2 = jy;
00388                 i__3 = jy;
00389                 i__4 = kk;
00390                 r__1 = ap[i__4].r;
00391                 q__2.r = r__1 * temp1.r, q__2.i = r__1 * temp1.i;
00392                 q__1.r = y[i__3].r + q__2.r, q__1.i = y[i__3].i + q__2.i;
00393                 y[i__2].r = q__1.r, y[i__2].i = q__1.i;
00394                 ix = jx;
00395                 iy = jy;
00396                 i__2 = kk + *n - j;
00397                 for (k = kk + 1; k <= i__2; ++k) {
00398                     ix += *incx;
00399                     iy += *incy;
00400                     i__3 = iy;
00401                     i__4 = iy;
00402                     i__5 = k;
00403                     q__2.r = temp1.r * ap[i__5].r - temp1.i * ap[i__5].i, 
00404                             q__2.i = temp1.r * ap[i__5].i + temp1.i * ap[i__5]
00405                             .r;
00406                     q__1.r = y[i__4].r + q__2.r, q__1.i = y[i__4].i + q__2.i;
00407                     y[i__3].r = q__1.r, y[i__3].i = q__1.i;
00408                     r_cnjg(&q__3, &ap[k]);
00409                     i__3 = ix;
00410                     q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i, q__2.i =
00411                              q__3.r * x[i__3].i + q__3.i * x[i__3].r;
00412                     q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
00413                     temp2.r = q__1.r, temp2.i = q__1.i;
00414 /* L110: */
00415                 }
00416                 i__2 = jy;
00417                 i__3 = jy;
00418                 q__2.r = alpha->r * temp2.r - alpha->i * temp2.i, q__2.i = 
00419                         alpha->r * temp2.i + alpha->i * temp2.r;
00420                 q__1.r = y[i__3].r + q__2.r, q__1.i = y[i__3].i + q__2.i;
00421                 y[i__2].r = q__1.r, y[i__2].i = q__1.i;
00422                 jx += *incx;
00423                 jy += *incy;
00424                 kk += *n - j + 1;
00425 /* L120: */
00426             }
00427         }
00428     }
00429 
00430     return 0;
00431 
00432 /*     End of CHPMV . */
00433 
00434 } /* chpmv_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:29