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


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