zhemm.c
Go to the documentation of this file.
00001 /* zhemm.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 zhemm_(char *side, char *uplo, integer *m, integer *n, 
00017         doublecomplex *alpha, doublecomplex *a, integer *lda, doublecomplex *
00018         b, integer *ldb, doublecomplex *beta, doublecomplex *c__, integer *
00019         ldc)
00020 {
00021     /* System generated locals */
00022     integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2, 
00023             i__3, i__4, i__5, i__6;
00024     doublereal d__1;
00025     doublecomplex z__1, z__2, z__3, z__4, z__5;
00026 
00027     /* Builtin functions */
00028     void d_cnjg(doublecomplex *, doublecomplex *);
00029 
00030     /* Local variables */
00031     integer i__, j, k, info;
00032     doublecomplex temp1, temp2;
00033     extern logical lsame_(char *, char *);
00034     integer nrowa;
00035     logical upper;
00036     extern /* Subroutine */ int xerbla_(char *, integer *);
00037 
00038 /*     .. Scalar Arguments .. */
00039 /*     .. */
00040 /*     .. Array Arguments .. */
00041 /*     .. */
00042 
00043 /*  Purpose */
00044 /*  ======= */
00045 
00046 /*  ZHEMM  performs one of the matrix-matrix operations */
00047 
00048 /*     C := alpha*A*B + beta*C, */
00049 
00050 /*  or */
00051 
00052 /*     C := alpha*B*A + beta*C, */
00053 
00054 /*  where alpha and beta are scalars, A is an hermitian matrix and  B and */
00055 /*  C are m by n matrices. */
00056 
00057 /*  Arguments */
00058 /*  ========== */
00059 
00060 /*  SIDE   - CHARACTER*1. */
00061 /*           On entry,  SIDE  specifies whether  the  hermitian matrix  A */
00062 /*           appears on the  left or right  in the  operation as follows: */
00063 
00064 /*              SIDE = 'L' or 'l'   C := alpha*A*B + beta*C, */
00065 
00066 /*              SIDE = 'R' or 'r'   C := alpha*B*A + beta*C, */
00067 
00068 /*           Unchanged on exit. */
00069 
00070 /*  UPLO   - CHARACTER*1. */
00071 /*           On  entry,   UPLO  specifies  whether  the  upper  or  lower */
00072 /*           triangular  part  of  the  hermitian  matrix   A  is  to  be */
00073 /*           referenced as follows: */
00074 
00075 /*              UPLO = 'U' or 'u'   Only the upper triangular part of the */
00076 /*                                  hermitian matrix is to be referenced. */
00077 
00078 /*              UPLO = 'L' or 'l'   Only the lower triangular part of the */
00079 /*                                  hermitian matrix is to be referenced. */
00080 
00081 /*           Unchanged on exit. */
00082 
00083 /*  M      - INTEGER. */
00084 /*           On entry,  M  specifies the number of rows of the matrix  C. */
00085 /*           M  must be at least zero. */
00086 /*           Unchanged on exit. */
00087 
00088 /*  N      - INTEGER. */
00089 /*           On entry, N specifies the number of columns of the matrix C. */
00090 /*           N  must be at least zero. */
00091 /*           Unchanged on exit. */
00092 
00093 /*  ALPHA  - COMPLEX*16      . */
00094 /*           On entry, ALPHA specifies the scalar alpha. */
00095 /*           Unchanged on exit. */
00096 
00097 /*  A      - COMPLEX*16       array of DIMENSION ( LDA, ka ), where ka is */
00098 /*           m  when  SIDE = 'L' or 'l'  and is n  otherwise. */
00099 /*           Before entry  with  SIDE = 'L' or 'l',  the  m by m  part of */
00100 /*           the array  A  must contain the  hermitian matrix,  such that */
00101 /*           when  UPLO = 'U' or 'u', the leading m by m upper triangular */
00102 /*           part of the array  A  must contain the upper triangular part */
00103 /*           of the  hermitian matrix and the  strictly  lower triangular */
00104 /*           part of  A  is not referenced,  and when  UPLO = 'L' or 'l', */
00105 /*           the leading  m by m  lower triangular part  of the  array  A */
00106 /*           must  contain  the  lower triangular part  of the  hermitian */
00107 /*           matrix and the  strictly upper triangular part of  A  is not */
00108 /*           referenced. */
00109 /*           Before entry  with  SIDE = 'R' or 'r',  the  n by n  part of */
00110 /*           the array  A  must contain the  hermitian matrix,  such that */
00111 /*           when  UPLO = 'U' or 'u', the leading n by n upper triangular */
00112 /*           part of the array  A  must contain the upper triangular part */
00113 /*           of the  hermitian matrix and the  strictly  lower triangular */
00114 /*           part of  A  is not referenced,  and when  UPLO = 'L' or 'l', */
00115 /*           the leading  n by n  lower triangular part  of the  array  A */
00116 /*           must  contain  the  lower triangular part  of the  hermitian */
00117 /*           matrix and the  strictly upper triangular part of  A  is not */
00118 /*           referenced. */
00119 /*           Note that the imaginary parts  of the diagonal elements need */
00120 /*           not be set, they are assumed to be zero. */
00121 /*           Unchanged on exit. */
00122 
00123 /*  LDA    - INTEGER. */
00124 /*           On entry, LDA specifies the first dimension of A as declared */
00125 /*           in the  calling (sub) program. When  SIDE = 'L' or 'l'  then */
00126 /*           LDA must be at least  max( 1, m ), otherwise  LDA must be at */
00127 /*           least max( 1, n ). */
00128 /*           Unchanged on exit. */
00129 
00130 /*  B      - COMPLEX*16       array of DIMENSION ( LDB, n ). */
00131 /*           Before entry, the leading  m by n part of the array  B  must */
00132 /*           contain the matrix B. */
00133 /*           Unchanged on exit. */
00134 
00135 /*  LDB    - INTEGER. */
00136 /*           On entry, LDB specifies the first dimension of B as declared */
00137 /*           in  the  calling  (sub)  program.   LDB  must  be  at  least */
00138 /*           max( 1, m ). */
00139 /*           Unchanged on exit. */
00140 
00141 /*  BETA   - COMPLEX*16      . */
00142 /*           On entry,  BETA  specifies the scalar  beta.  When  BETA  is */
00143 /*           supplied as zero then C need not be set on input. */
00144 /*           Unchanged on exit. */
00145 
00146 /*  C      - COMPLEX*16       array of DIMENSION ( LDC, n ). */
00147 /*           Before entry, the leading  m by n  part of the array  C must */
00148 /*           contain the matrix  C,  except when  beta  is zero, in which */
00149 /*           case C need not be set on entry. */
00150 /*           On exit, the array  C  is overwritten by the  m by n updated */
00151 /*           matrix. */
00152 
00153 /*  LDC    - INTEGER. */
00154 /*           On entry, LDC specifies the first dimension of C as declared */
00155 /*           in  the  calling  (sub)  program.   LDC  must  be  at  least */
00156 /*           max( 1, m ). */
00157 /*           Unchanged on exit. */
00158 
00159 
00160 /*  Level 3 Blas routine. */
00161 
00162 /*  -- Written on 8-February-1989. */
00163 /*     Jack Dongarra, Argonne National Laboratory. */
00164 /*     Iain Duff, AERE Harwell. */
00165 /*     Jeremy Du Croz, Numerical Algorithms Group Ltd. */
00166 /*     Sven Hammarling, Numerical Algorithms Group Ltd. */
00167 
00168 
00169 /*     .. External Functions .. */
00170 /*     .. */
00171 /*     .. External Subroutines .. */
00172 /*     .. */
00173 /*     .. Intrinsic Functions .. */
00174 /*     .. */
00175 /*     .. Local Scalars .. */
00176 /*     .. */
00177 /*     .. Parameters .. */
00178 /*     .. */
00179 
00180 /*     Set NROWA as the number of rows of A. */
00181 
00182     /* Parameter adjustments */
00183     a_dim1 = *lda;
00184     a_offset = 1 + a_dim1;
00185     a -= a_offset;
00186     b_dim1 = *ldb;
00187     b_offset = 1 + b_dim1;
00188     b -= b_offset;
00189     c_dim1 = *ldc;
00190     c_offset = 1 + c_dim1;
00191     c__ -= c_offset;
00192 
00193     /* Function Body */
00194     if (lsame_(side, "L")) {
00195         nrowa = *m;
00196     } else {
00197         nrowa = *n;
00198     }
00199     upper = lsame_(uplo, "U");
00200 
00201 /*     Test the input parameters. */
00202 
00203     info = 0;
00204     if (! lsame_(side, "L") && ! lsame_(side, "R")) {
00205         info = 1;
00206     } else if (! upper && ! lsame_(uplo, "L")) {
00207         info = 2;
00208     } else if (*m < 0) {
00209         info = 3;
00210     } else if (*n < 0) {
00211         info = 4;
00212     } else if (*lda < max(1,nrowa)) {
00213         info = 7;
00214     } else if (*ldb < max(1,*m)) {
00215         info = 9;
00216     } else if (*ldc < max(1,*m)) {
00217         info = 12;
00218     }
00219     if (info != 0) {
00220         xerbla_("ZHEMM ", &info);
00221         return 0;
00222     }
00223 
00224 /*     Quick return if possible. */
00225 
00226     if (*m == 0 || *n == 0 || alpha->r == 0. && alpha->i == 0. && (beta->r == 
00227             1. && beta->i == 0.)) {
00228         return 0;
00229     }
00230 
00231 /*     And when  alpha.eq.zero. */
00232 
00233     if (alpha->r == 0. && alpha->i == 0.) {
00234         if (beta->r == 0. && beta->i == 0.) {
00235             i__1 = *n;
00236             for (j = 1; j <= i__1; ++j) {
00237                 i__2 = *m;
00238                 for (i__ = 1; i__ <= i__2; ++i__) {
00239                     i__3 = i__ + j * c_dim1;
00240                     c__[i__3].r = 0., c__[i__3].i = 0.;
00241 /* L10: */
00242                 }
00243 /* L20: */
00244             }
00245         } else {
00246             i__1 = *n;
00247             for (j = 1; j <= i__1; ++j) {
00248                 i__2 = *m;
00249                 for (i__ = 1; i__ <= i__2; ++i__) {
00250                     i__3 = i__ + j * c_dim1;
00251                     i__4 = i__ + j * c_dim1;
00252                     z__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4].i, 
00253                             z__1.i = beta->r * c__[i__4].i + beta->i * c__[
00254                             i__4].r;
00255                     c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
00256 /* L30: */
00257                 }
00258 /* L40: */
00259             }
00260         }
00261         return 0;
00262     }
00263 
00264 /*     Start the operations. */
00265 
00266     if (lsame_(side, "L")) {
00267 
00268 /*        Form  C := alpha*A*B + beta*C. */
00269 
00270         if (upper) {
00271             i__1 = *n;
00272             for (j = 1; j <= i__1; ++j) {
00273                 i__2 = *m;
00274                 for (i__ = 1; i__ <= i__2; ++i__) {
00275                     i__3 = i__ + j * b_dim1;
00276                     z__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3].i, 
00277                             z__1.i = alpha->r * b[i__3].i + alpha->i * b[i__3]
00278                             .r;
00279                     temp1.r = z__1.r, temp1.i = z__1.i;
00280                     temp2.r = 0., temp2.i = 0.;
00281                     i__3 = i__ - 1;
00282                     for (k = 1; k <= i__3; ++k) {
00283                         i__4 = k + j * c_dim1;
00284                         i__5 = k + j * c_dim1;
00285                         i__6 = k + i__ * a_dim1;
00286                         z__2.r = temp1.r * a[i__6].r - temp1.i * a[i__6].i, 
00287                                 z__2.i = temp1.r * a[i__6].i + temp1.i * a[
00288                                 i__6].r;
00289                         z__1.r = c__[i__5].r + z__2.r, z__1.i = c__[i__5].i + 
00290                                 z__2.i;
00291                         c__[i__4].r = z__1.r, c__[i__4].i = z__1.i;
00292                         i__4 = k + j * b_dim1;
00293                         d_cnjg(&z__3, &a[k + i__ * a_dim1]);
00294                         z__2.r = b[i__4].r * z__3.r - b[i__4].i * z__3.i, 
00295                                 z__2.i = b[i__4].r * z__3.i + b[i__4].i * 
00296                                 z__3.r;
00297                         z__1.r = temp2.r + z__2.r, z__1.i = temp2.i + z__2.i;
00298                         temp2.r = z__1.r, temp2.i = z__1.i;
00299 /* L50: */
00300                     }
00301                     if (beta->r == 0. && beta->i == 0.) {
00302                         i__3 = i__ + j * c_dim1;
00303                         i__4 = i__ + i__ * a_dim1;
00304                         d__1 = a[i__4].r;
00305                         z__2.r = d__1 * temp1.r, z__2.i = d__1 * temp1.i;
00306                         z__3.r = alpha->r * temp2.r - alpha->i * temp2.i, 
00307                                 z__3.i = alpha->r * temp2.i + alpha->i * 
00308                                 temp2.r;
00309                         z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00310                         c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
00311                     } else {
00312                         i__3 = i__ + j * c_dim1;
00313                         i__4 = i__ + j * c_dim1;
00314                         z__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
00315                                 .i, z__3.i = beta->r * c__[i__4].i + beta->i *
00316                                  c__[i__4].r;
00317                         i__5 = i__ + i__ * a_dim1;
00318                         d__1 = a[i__5].r;
00319                         z__4.r = d__1 * temp1.r, z__4.i = d__1 * temp1.i;
00320                         z__2.r = z__3.r + z__4.r, z__2.i = z__3.i + z__4.i;
00321                         z__5.r = alpha->r * temp2.r - alpha->i * temp2.i, 
00322                                 z__5.i = alpha->r * temp2.i + alpha->i * 
00323                                 temp2.r;
00324                         z__1.r = z__2.r + z__5.r, z__1.i = z__2.i + z__5.i;
00325                         c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
00326                     }
00327 /* L60: */
00328                 }
00329 /* L70: */
00330             }
00331         } else {
00332             i__1 = *n;
00333             for (j = 1; j <= i__1; ++j) {
00334                 for (i__ = *m; i__ >= 1; --i__) {
00335                     i__2 = i__ + j * b_dim1;
00336                     z__1.r = alpha->r * b[i__2].r - alpha->i * b[i__2].i, 
00337                             z__1.i = alpha->r * b[i__2].i + alpha->i * b[i__2]
00338                             .r;
00339                     temp1.r = z__1.r, temp1.i = z__1.i;
00340                     temp2.r = 0., temp2.i = 0.;
00341                     i__2 = *m;
00342                     for (k = i__ + 1; k <= i__2; ++k) {
00343                         i__3 = k + j * c_dim1;
00344                         i__4 = k + j * c_dim1;
00345                         i__5 = k + i__ * a_dim1;
00346                         z__2.r = temp1.r * a[i__5].r - temp1.i * a[i__5].i, 
00347                                 z__2.i = temp1.r * a[i__5].i + temp1.i * a[
00348                                 i__5].r;
00349                         z__1.r = c__[i__4].r + z__2.r, z__1.i = c__[i__4].i + 
00350                                 z__2.i;
00351                         c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
00352                         i__3 = k + j * b_dim1;
00353                         d_cnjg(&z__3, &a[k + i__ * a_dim1]);
00354                         z__2.r = b[i__3].r * z__3.r - b[i__3].i * z__3.i, 
00355                                 z__2.i = b[i__3].r * z__3.i + b[i__3].i * 
00356                                 z__3.r;
00357                         z__1.r = temp2.r + z__2.r, z__1.i = temp2.i + z__2.i;
00358                         temp2.r = z__1.r, temp2.i = z__1.i;
00359 /* L80: */
00360                     }
00361                     if (beta->r == 0. && beta->i == 0.) {
00362                         i__2 = i__ + j * c_dim1;
00363                         i__3 = i__ + i__ * a_dim1;
00364                         d__1 = a[i__3].r;
00365                         z__2.r = d__1 * temp1.r, z__2.i = d__1 * temp1.i;
00366                         z__3.r = alpha->r * temp2.r - alpha->i * temp2.i, 
00367                                 z__3.i = alpha->r * temp2.i + alpha->i * 
00368                                 temp2.r;
00369                         z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00370                         c__[i__2].r = z__1.r, c__[i__2].i = z__1.i;
00371                     } else {
00372                         i__2 = i__ + j * c_dim1;
00373                         i__3 = i__ + j * c_dim1;
00374                         z__3.r = beta->r * c__[i__3].r - beta->i * c__[i__3]
00375                                 .i, z__3.i = beta->r * c__[i__3].i + beta->i *
00376                                  c__[i__3].r;
00377                         i__4 = i__ + i__ * a_dim1;
00378                         d__1 = a[i__4].r;
00379                         z__4.r = d__1 * temp1.r, z__4.i = d__1 * temp1.i;
00380                         z__2.r = z__3.r + z__4.r, z__2.i = z__3.i + z__4.i;
00381                         z__5.r = alpha->r * temp2.r - alpha->i * temp2.i, 
00382                                 z__5.i = alpha->r * temp2.i + alpha->i * 
00383                                 temp2.r;
00384                         z__1.r = z__2.r + z__5.r, z__1.i = z__2.i + z__5.i;
00385                         c__[i__2].r = z__1.r, c__[i__2].i = z__1.i;
00386                     }
00387 /* L90: */
00388                 }
00389 /* L100: */
00390             }
00391         }
00392     } else {
00393 
00394 /*        Form  C := alpha*B*A + beta*C. */
00395 
00396         i__1 = *n;
00397         for (j = 1; j <= i__1; ++j) {
00398             i__2 = j + j * a_dim1;
00399             d__1 = a[i__2].r;
00400             z__1.r = d__1 * alpha->r, z__1.i = d__1 * alpha->i;
00401             temp1.r = z__1.r, temp1.i = z__1.i;
00402             if (beta->r == 0. && beta->i == 0.) {
00403                 i__2 = *m;
00404                 for (i__ = 1; i__ <= i__2; ++i__) {
00405                     i__3 = i__ + j * c_dim1;
00406                     i__4 = i__ + j * b_dim1;
00407                     z__1.r = temp1.r * b[i__4].r - temp1.i * b[i__4].i, 
00408                             z__1.i = temp1.r * b[i__4].i + temp1.i * b[i__4]
00409                             .r;
00410                     c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
00411 /* L110: */
00412                 }
00413             } else {
00414                 i__2 = *m;
00415                 for (i__ = 1; i__ <= i__2; ++i__) {
00416                     i__3 = i__ + j * c_dim1;
00417                     i__4 = i__ + j * c_dim1;
00418                     z__2.r = beta->r * c__[i__4].r - beta->i * c__[i__4].i, 
00419                             z__2.i = beta->r * c__[i__4].i + beta->i * c__[
00420                             i__4].r;
00421                     i__5 = i__ + j * b_dim1;
00422                     z__3.r = temp1.r * b[i__5].r - temp1.i * b[i__5].i, 
00423                             z__3.i = temp1.r * b[i__5].i + temp1.i * b[i__5]
00424                             .r;
00425                     z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00426                     c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
00427 /* L120: */
00428                 }
00429             }
00430             i__2 = j - 1;
00431             for (k = 1; k <= i__2; ++k) {
00432                 if (upper) {
00433                     i__3 = k + j * a_dim1;
00434                     z__1.r = alpha->r * a[i__3].r - alpha->i * a[i__3].i, 
00435                             z__1.i = alpha->r * a[i__3].i + alpha->i * a[i__3]
00436                             .r;
00437                     temp1.r = z__1.r, temp1.i = z__1.i;
00438                 } else {
00439                     d_cnjg(&z__2, &a[j + k * a_dim1]);
00440                     z__1.r = alpha->r * z__2.r - alpha->i * z__2.i, z__1.i = 
00441                             alpha->r * z__2.i + alpha->i * z__2.r;
00442                     temp1.r = z__1.r, temp1.i = z__1.i;
00443                 }
00444                 i__3 = *m;
00445                 for (i__ = 1; i__ <= i__3; ++i__) {
00446                     i__4 = i__ + j * c_dim1;
00447                     i__5 = i__ + j * c_dim1;
00448                     i__6 = i__ + k * b_dim1;
00449                     z__2.r = temp1.r * b[i__6].r - temp1.i * b[i__6].i, 
00450                             z__2.i = temp1.r * b[i__6].i + temp1.i * b[i__6]
00451                             .r;
00452                     z__1.r = c__[i__5].r + z__2.r, z__1.i = c__[i__5].i + 
00453                             z__2.i;
00454                     c__[i__4].r = z__1.r, c__[i__4].i = z__1.i;
00455 /* L130: */
00456                 }
00457 /* L140: */
00458             }
00459             i__2 = *n;
00460             for (k = j + 1; k <= i__2; ++k) {
00461                 if (upper) {
00462                     d_cnjg(&z__2, &a[j + k * a_dim1]);
00463                     z__1.r = alpha->r * z__2.r - alpha->i * z__2.i, z__1.i = 
00464                             alpha->r * z__2.i + alpha->i * z__2.r;
00465                     temp1.r = z__1.r, temp1.i = z__1.i;
00466                 } else {
00467                     i__3 = k + j * a_dim1;
00468                     z__1.r = alpha->r * a[i__3].r - alpha->i * a[i__3].i, 
00469                             z__1.i = alpha->r * a[i__3].i + alpha->i * a[i__3]
00470                             .r;
00471                     temp1.r = z__1.r, temp1.i = z__1.i;
00472                 }
00473                 i__3 = *m;
00474                 for (i__ = 1; i__ <= i__3; ++i__) {
00475                     i__4 = i__ + j * c_dim1;
00476                     i__5 = i__ + j * c_dim1;
00477                     i__6 = i__ + k * b_dim1;
00478                     z__2.r = temp1.r * b[i__6].r - temp1.i * b[i__6].i, 
00479                             z__2.i = temp1.r * b[i__6].i + temp1.i * b[i__6]
00480                             .r;
00481                     z__1.r = c__[i__5].r + z__2.r, z__1.i = c__[i__5].i + 
00482                             z__2.i;
00483                     c__[i__4].r = z__1.r, c__[i__4].i = z__1.i;
00484 /* L150: */
00485                 }
00486 /* L160: */
00487             }
00488 /* L170: */
00489         }
00490     }
00491 
00492     return 0;
00493 
00494 /*     End of ZHEMM . */
00495 
00496 } /* zhemm_ */


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