chemv.c
Go to the documentation of this file.
00001 /* chemv.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 chemv_(char *uplo, integer *n, complex *alpha, complex *
00017         a, integer *lda, complex *x, integer *incx, complex *beta, complex *y, 
00018          integer *incy)
00019 {
00020     /* System generated locals */
00021     integer a_dim1, a_offset, 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, 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 /*  CHEMV  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         . */
00071 /*           On entry, ALPHA specifies the scalar alpha. */
00072 /*           Unchanged on exit. */
00073 
00074 /*  A      - COMPLEX          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          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         . */
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          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_("CHEMV ", &info);
00165         return 0;
00166     }
00167 
00168 /*     Quick return if possible. */
00169 
00170     if (*n == 0 || alpha->r == 0.f && alpha->i == 0.f && (beta->r == 1.f && 
00171             beta->i == 0.f)) {
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.f || beta->i != 0.f) {
00195         if (*incy == 1) {
00196             if (beta->r == 0.f && beta->i == 0.f) {
00197                 i__1 = *n;
00198                 for (i__ = 1; i__ <= i__1; ++i__) {
00199                     i__2 = i__;
00200                     y[i__2].r = 0.f, y[i__2].i = 0.f;
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                     q__1.r = beta->r * y[i__3].r - beta->i * y[i__3].i, 
00209                             q__1.i = beta->r * y[i__3].i + beta->i * y[i__3]
00210                             .r;
00211                     y[i__2].r = q__1.r, y[i__2].i = q__1.i;
00212 /* L20: */
00213                 }
00214             }
00215         } else {
00216             iy = ky;
00217             if (beta->r == 0.f && beta->i == 0.f) {
00218                 i__1 = *n;
00219                 for (i__ = 1; i__ <= i__1; ++i__) {
00220                     i__2 = iy;
00221                     y[i__2].r = 0.f, y[i__2].i = 0.f;
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                     q__1.r = beta->r * y[i__3].r - beta->i * y[i__3].i, 
00231                             q__1.i = beta->r * y[i__3].i + beta->i * y[i__3]
00232                             .r;
00233                     y[i__2].r = q__1.r, y[i__2].i = q__1.i;
00234                     iy += *incy;
00235 /* L40: */
00236                 }
00237             }
00238         }
00239     }
00240     if (alpha->r == 0.f && alpha->i == 0.f) {
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                 q__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, q__1.i =
00252                          alpha->r * x[i__2].i + alpha->i * x[i__2].r;
00253                 temp1.r = q__1.r, temp1.i = q__1.i;
00254                 temp2.r = 0.f, temp2.i = 0.f;
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                     q__2.r = temp1.r * a[i__5].r - temp1.i * a[i__5].i, 
00261                             q__2.i = temp1.r * a[i__5].i + temp1.i * a[i__5]
00262                             .r;
00263                     q__1.r = y[i__4].r + q__2.r, q__1.i = y[i__4].i + q__2.i;
00264                     y[i__3].r = q__1.r, y[i__3].i = q__1.i;
00265                     r_cnjg(&q__3, &a[i__ + j * a_dim1]);
00266                     i__3 = i__;
00267                     q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i, q__2.i =
00268                              q__3.r * x[i__3].i + q__3.i * x[i__3].r;
00269                     q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
00270                     temp2.r = q__1.r, temp2.i = q__1.i;
00271 /* L50: */
00272                 }
00273                 i__2 = j;
00274                 i__3 = j;
00275                 i__4 = j + j * a_dim1;
00276                 r__1 = a[i__4].r;
00277                 q__3.r = r__1 * temp1.r, q__3.i = r__1 * temp1.i;
00278                 q__2.r = y[i__3].r + q__3.r, q__2.i = y[i__3].i + q__3.i;
00279                 q__4.r = alpha->r * temp2.r - alpha->i * temp2.i, q__4.i = 
00280                         alpha->r * temp2.i + alpha->i * temp2.r;
00281                 q__1.r = q__2.r + q__4.r, q__1.i = q__2.i + q__4.i;
00282                 y[i__2].r = q__1.r, y[i__2].i = q__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                 q__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, q__1.i =
00292                          alpha->r * x[i__2].i + alpha->i * x[i__2].r;
00293                 temp1.r = q__1.r, temp1.i = q__1.i;
00294                 temp2.r = 0.f, temp2.i = 0.f;
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                     q__2.r = temp1.r * a[i__5].r - temp1.i * a[i__5].i, 
00303                             q__2.i = temp1.r * a[i__5].i + temp1.i * a[i__5]
00304                             .r;
00305                     q__1.r = y[i__4].r + q__2.r, q__1.i = y[i__4].i + q__2.i;
00306                     y[i__3].r = q__1.r, y[i__3].i = q__1.i;
00307                     r_cnjg(&q__3, &a[i__ + j * a_dim1]);
00308                     i__3 = ix;
00309                     q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i, q__2.i =
00310                              q__3.r * x[i__3].i + q__3.i * x[i__3].r;
00311                     q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
00312                     temp2.r = q__1.r, temp2.i = q__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                 r__1 = a[i__4].r;
00321                 q__3.r = r__1 * temp1.r, q__3.i = r__1 * temp1.i;
00322                 q__2.r = y[i__3].r + q__3.r, q__2.i = y[i__3].i + q__3.i;
00323                 q__4.r = alpha->r * temp2.r - alpha->i * temp2.i, q__4.i = 
00324                         alpha->r * temp2.i + alpha->i * temp2.r;
00325                 q__1.r = q__2.r + q__4.r, q__1.i = q__2.i + q__4.i;
00326                 y[i__2].r = q__1.r, y[i__2].i = q__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                 q__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, q__1.i =
00341                          alpha->r * x[i__2].i + alpha->i * x[i__2].r;
00342                 temp1.r = q__1.r, temp1.i = q__1.i;
00343                 temp2.r = 0.f, temp2.i = 0.f;
00344                 i__2 = j;
00345                 i__3 = j;
00346                 i__4 = j + j * a_dim1;
00347                 r__1 = a[i__4].r;
00348                 q__2.r = r__1 * temp1.r, q__2.i = r__1 * temp1.i;
00349                 q__1.r = y[i__3].r + q__2.r, q__1.i = y[i__3].i + q__2.i;
00350                 y[i__2].r = q__1.r, y[i__2].i = q__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                     q__2.r = temp1.r * a[i__5].r - temp1.i * a[i__5].i, 
00357                             q__2.i = temp1.r * a[i__5].i + temp1.i * a[i__5]
00358                             .r;
00359                     q__1.r = y[i__4].r + q__2.r, q__1.i = y[i__4].i + q__2.i;
00360                     y[i__3].r = q__1.r, y[i__3].i = q__1.i;
00361                     r_cnjg(&q__3, &a[i__ + j * a_dim1]);
00362                     i__3 = i__;
00363                     q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i, q__2.i =
00364                              q__3.r * x[i__3].i + q__3.i * x[i__3].r;
00365                     q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
00366                     temp2.r = q__1.r, temp2.i = q__1.i;
00367 /* L90: */
00368                 }
00369                 i__2 = j;
00370                 i__3 = j;
00371                 q__2.r = alpha->r * temp2.r - alpha->i * temp2.i, q__2.i = 
00372                         alpha->r * temp2.i + alpha->i * temp2.r;
00373                 q__1.r = y[i__3].r + q__2.r, q__1.i = y[i__3].i + q__2.i;
00374                 y[i__2].r = q__1.r, y[i__2].i = q__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                 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 = j + j * a_dim1;
00390                 r__1 = a[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 = *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                     q__2.r = temp1.r * a[i__5].r - temp1.i * a[i__5].i, 
00404                             q__2.i = temp1.r * a[i__5].i + temp1.i * a[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, &a[i__ + j * a_dim1]);
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 /* L120: */
00425             }
00426         }
00427     }
00428 
00429     return 0;
00430 
00431 /*     End of CHEMV . */
00432 
00433 } /* chemv_ */


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