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


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