Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

dgemm.c

Go to the documentation of this file.
00001 /* DGEMM.F -- translated by f2c (version 19941215).
00002    You must link the resulting object file with the libraries:
00003         -lf2c -lm   (in that order)
00004 */
00005 
00006 #include "f2c.h"
00007 #include "cblasimpexp.h"
00008 
00009 /* *********************************************************************** */
00010 
00011 /*     File of the DOUBLE PRECISION Level-3 BLAS. */
00012 /*     ========================================== */
00013 
00014 /*     SUBROUTINE DGEMM ( TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, */
00015 /*    $                   BETA, C, LDC ) */
00016 
00017 /*     SUBROUTINE DSYMM ( SIDE,   UPLO,   M, N,    ALPHA, A, LDA, B, LDB, */
00018 /*    $                   BETA, C, LDC ) */
00019 
00020 /*     SUBROUTINE DSYRK ( UPLO,   TRANS,     N, K, ALPHA, A, LDA, */
00021 /*    $                   BETA, C, LDC ) */
00022 
00023 /*     SUBROUTINE DSYR2K( UPLO,   TRANS,     N, K, ALPHA, A, LDA, B, LDB, */
00024 /*    $                   BETA, C, LDC ) */
00025 
00026 /*     SUBROUTINE DTRMM ( SIDE, UPLO, TRANSA, DIAG, M, N, ALPHA, A, LDA, */
00027 /*    $                   B, LDB ) */
00028 
00029 /*     SUBROUTINE DTRSM ( SIDE, UPLO, TRANSA, DIAG, M, N, ALPHA, A, LDA, */
00030 /*    $                   B, LDB ) */
00031 
00032 /*     See: */
00033 
00034 /*        Dongarra J. J.,   Du Croz J. J.,   Duff I.  and   Hammarling S. */
00035 /*        A set of  Level 3  Basic Linear Algebra Subprograms.  Technical */
00036 /*        Memorandum No.88 (Revision 1), Mathematics and Computer Science */
00037 /*        Division,  Argonne National Laboratory, 9700 South Cass Avenue, */
00038 /*        Argonne, Illinois 60439. */
00039 
00040 
00041 /* *********************************************************************** */
00042 
00043 /* Subroutine */ int __IMPEXP__ dgemm_(transa, transb, m, n, k, alpha, a, lda, b, ldb, 
00044         beta, c, ldc, transa_len, transb_len)
00045 char *transa, *transb;
00046 integer *m, *n, *k;
00047 doublereal *alpha, *a;
00048 integer *lda;
00049 doublereal *b;
00050 integer *ldb;
00051 doublereal *beta, *c;
00052 integer *ldc;
00053 ftnlen transa_len;
00054 ftnlen transb_len;
00055 {
00056     /* System generated locals */
00057     integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2, 
00058             i__3;
00059 
00060     /* Local variables */
00061     static integer info;
00062     static logical nota, notb;
00063     static doublereal temp;
00064     static integer i, j, l, ncola;
00065     extern logical lsame_();
00066     static integer nrowa, nrowb;
00067     extern /* Subroutine */ int xerbla_();
00068 
00069 /*     .. Scalar Arguments .. */
00070 /*     .. Array Arguments .. */
00071 /*     .. */
00072 
00073 /*  Purpose */
00074 /*  ======= */
00075 
00076 /*  DGEMM  performs one of the matrix-matrix operations */
00077 
00078 /*     C := alpha*op( A )*op( B ) + beta*C, */
00079 
00080 /*  where  op( X ) is one of */
00081 
00082 /*     op( X ) = X   or   op( X ) = X', */
00083 
00084 /*  alpha and beta are scalars, and A, B and C are matrices, with op( A ) 
00085 */
00086 /*  an m by k matrix,  op( B )  a  k by n matrix and  C an m by n matrix. 
00087 */
00088 
00089 /*  Parameters */
00090 /*  ========== */
00091 
00092 /*  TRANSA - CHARACTER*1. */
00093 /*           On entry, TRANSA specifies the form of op( A ) to be used in 
00094 */
00095 /*           the matrix multiplication as follows: */
00096 
00097 /*              TRANSA = 'N' or 'n',  op( A ) = A. */
00098 
00099 /*              TRANSA = 'T' or 't',  op( A ) = A'. */
00100 
00101 /*              TRANSA = 'C' or 'c',  op( A ) = A'. */
00102 
00103 /*           Unchanged on exit. */
00104 
00105 /*  TRANSB - CHARACTER*1. */
00106 /*           On entry, TRANSB specifies the form of op( B ) to be used in 
00107 */
00108 /*           the matrix multiplication as follows: */
00109 
00110 /*              TRANSB = 'N' or 'n',  op( B ) = B. */
00111 
00112 /*              TRANSB = 'T' or 't',  op( B ) = B'. */
00113 
00114 /*              TRANSB = 'C' or 'c',  op( B ) = B'. */
00115 
00116 /*           Unchanged on exit. */
00117 
00118 /*  M      - INTEGER. */
00119 /*           On entry,  M  specifies  the number  of rows  of the  matrix 
00120 */
00121 /*           op( A )  and of the  matrix  C.  M  must  be at least  zero. 
00122 */
00123 /*           Unchanged on exit. */
00124 
00125 /*  N      - INTEGER. */
00126 /*           On entry,  N  specifies the number  of columns of the matrix 
00127 */
00128 /*           op( B ) and the number of columns of the matrix C. N must be 
00129 */
00130 /*           at least zero. */
00131 /*           Unchanged on exit. */
00132 
00133 /*  K      - INTEGER. */
00134 /*           On entry,  K  specifies  the number of columns of the matrix 
00135 */
00136 /*           op( A ) and the number of rows of the matrix op( B ). K must 
00137 */
00138 /*           be at least  zero. */
00139 /*           Unchanged on exit. */
00140 
00141 /*  ALPHA  - DOUBLE PRECISION. */
00142 /*           On entry, ALPHA specifies the scalar alpha. */
00143 /*           Unchanged on exit. */
00144 
00145 /*  A      - DOUBLE PRECISION array of DIMENSION ( LDA, ka ), where ka is 
00146 */
00147 /*           k  when  TRANSA = 'N' or 'n',  and is  m  otherwise. */
00148 /*           Before entry with  TRANSA = 'N' or 'n',  the leading  m by k 
00149 */
00150 /*           part of the array  A  must contain the matrix  A,  otherwise 
00151 */
00152 /*           the leading  k by m  part of the array  A  must contain  the 
00153 */
00154 /*           matrix A. */
00155 /*           Unchanged on exit. */
00156 
00157 /*  LDA    - INTEGER. */
00158 /*           On entry, LDA specifies the first dimension of A as declared 
00159 */
00160 /*           in the calling (sub) program. When  TRANSA = 'N' or 'n' then 
00161 */
00162 /*           LDA must be at least  max( 1, m ), otherwise  LDA must be at 
00163 */
00164 /*           least  max( 1, k ). */
00165 /*           Unchanged on exit. */
00166 
00167 /*  B      - DOUBLE PRECISION array of DIMENSION ( LDB, kb ), where kb is 
00168 */
00169 /*           n  when  TRANSB = 'N' or 'n',  and is  k  otherwise. */
00170 /*           Before entry with  TRANSB = 'N' or 'n',  the leading  k by n 
00171 */
00172 /*           part of the array  B  must contain the matrix  B,  otherwise 
00173 */
00174 /*           the leading  n by k  part of the array  B  must contain  the 
00175 */
00176 /*           matrix B. */
00177 /*           Unchanged on exit. */
00178 
00179 /*  LDB    - INTEGER. */
00180 /*           On entry, LDB specifies the first dimension of B as declared 
00181 */
00182 /*           in the calling (sub) program. When  TRANSB = 'N' or 'n' then 
00183 */
00184 /*           LDB must be at least  max( 1, k ), otherwise  LDB must be at 
00185 */
00186 /*           least  max( 1, n ). */
00187 /*           Unchanged on exit. */
00188 
00189 /*  BETA   - DOUBLE PRECISION. */
00190 /*           On entry,  BETA  specifies the scalar  beta.  When  BETA  is 
00191 */
00192 /*           supplied as zero then C need not be set on input. */
00193 /*           Unchanged on exit. */
00194 
00195 /*  C      - DOUBLE PRECISION array of DIMENSION ( LDC, n ). */
00196 /*           Before entry, the leading  m by n  part of the array  C must 
00197 */
00198 /*           contain the matrix  C,  except when  beta  is zero, in which 
00199 */
00200 /*           case C need not be set on entry. */
00201 /*           On exit, the array  C  is overwritten by the  m by n  matrix 
00202 */
00203 /*           ( alpha*op( A )*op( B ) + beta*C ). */
00204 
00205 /*  LDC    - INTEGER. */
00206 /*           On entry, LDC specifies the first dimension of C as declared 
00207 */
00208 /*           in  the  calling  (sub)  program.   LDC  must  be  at  least 
00209 */
00210 /*           max( 1, m ). */
00211 /*           Unchanged on exit. */
00212 
00213 
00214 /*  Level 3 Blas routine. */
00215 
00216 /*  -- Written on 8-February-1989. */
00217 /*     Jack Dongarra, Argonne National Laboratory. */
00218 /*     Iain Duff, AERE Harwell. */
00219 /*     Jeremy Du Croz, Numerical Algorithms Group Ltd. */
00220 /*     Sven Hammarling, Numerical Algorithms Group Ltd. */
00221 
00222 
00223 /*     .. External Functions .. */
00224 /*     .. External Subroutines .. */
00225 /*     .. Intrinsic Functions .. */
00226 /*     .. Local Scalars .. */
00227 /*     .. Parameters .. */
00228 /*     .. */
00229 /*     .. Executable Statements .. */
00230 
00231 /*     Set  NOTA  and  NOTB  as  true if  A  and  B  respectively are not 
00232 */
00233 /*     transposed and set  NROWA, NCOLA and  NROWB  as the number of rows 
00234 */
00235 /*     and  columns of  A  and the  number of  rows  of  B  respectively. 
00236 */
00237 
00238     /* Parameter adjustments */
00239     a_dim1 = *lda;
00240     a_offset = a_dim1 + 1;
00241     a -= a_offset;
00242     b_dim1 = *ldb;
00243     b_offset = b_dim1 + 1;
00244     b -= b_offset;
00245     c_dim1 = *ldc;
00246     c_offset = c_dim1 + 1;
00247     c -= c_offset;
00248 
00249     /* Function Body */
00250     nota = lsame_(transa, "N", 1L, 1L);
00251     notb = lsame_(transb, "N", 1L, 1L);
00252     if (nota) {
00253         nrowa = *m;
00254         ncola = *k;
00255     } else {
00256         nrowa = *k;
00257         ncola = *m;
00258     }
00259     if (notb) {
00260         nrowb = *k;
00261     } else {
00262         nrowb = *n;
00263     }
00264 
00265 /*     Test the input parameters. */
00266 
00267     info = 0;
00268     if (! nota && ! lsame_(transa, "C", 1L, 1L) && ! lsame_(transa, "T", 1L, 
00269             1L)) {
00270         info = 1;
00271     } else if (! notb && ! lsame_(transb, "C", 1L, 1L) && ! lsame_(transb, 
00272             "T", 1L, 1L)) {
00273         info = 2;
00274     } else if (*m < 0) {
00275         info = 3;
00276     } else if (*n < 0) {
00277         info = 4;
00278     } else if (*k < 0) {
00279         info = 5;
00280     } else if (*lda < max(1,nrowa)) {
00281         info = 8;
00282     } else if (*ldb < max(1,nrowb)) {
00283         info = 10;
00284     } else if (*ldc < max(1,*m)) {
00285         info = 13;
00286     }
00287     if (info != 0) {
00288         xerbla_("DGEMM ", &info, 6L);
00289         return 0;
00290     }
00291 
00292 /*     Quick return if possible. */
00293 
00294     if (*m == 0 || *n == 0 || (*alpha == 0. || *k == 0) && *beta == 1.) {
00295         return 0;
00296     }
00297 
00298 /*     And if  alpha.eq.zero. */
00299 
00300     if (*alpha == 0.) {
00301         if (*beta == 0.) {
00302             i__1 = *n;
00303             for (j = 1; j <= i__1; ++j) {
00304                 i__2 = *m;
00305                 for (i = 1; i <= i__2; ++i) {
00306                     c[i + j * c_dim1] = 0.;
00307 /* L10: */
00308                 }
00309 /* L20: */
00310             }
00311         } else {
00312             i__1 = *n;
00313             for (j = 1; j <= i__1; ++j) {
00314                 i__2 = *m;
00315                 for (i = 1; i <= i__2; ++i) {
00316                     c[i + j * c_dim1] = *beta * c[i + j * c_dim1];
00317 /* L30: */
00318                 }
00319 /* L40: */
00320             }
00321         }
00322         return 0;
00323     }
00324 
00325 /*     Start the operations. */
00326 
00327     if (notb) {
00328         if (nota) {
00329 
00330 /*           Form  C := alpha*A*B + beta*C. */
00331 
00332             i__1 = *n;
00333             for (j = 1; j <= i__1; ++j) {
00334                 if (*beta == 0.) {
00335                     i__2 = *m;
00336                     for (i = 1; i <= i__2; ++i) {
00337                         c[i + j * c_dim1] = 0.;
00338 /* L50: */
00339                     }
00340                 } else if (*beta != 1.) {
00341                     i__2 = *m;
00342                     for (i = 1; i <= i__2; ++i) {
00343                         c[i + j * c_dim1] = *beta * c[i + j * c_dim1];
00344 /* L60: */
00345                     }
00346                 }
00347                 i__2 = *k;
00348                 for (l = 1; l <= i__2; ++l) {
00349                     if (b[l + j * b_dim1] != 0.) {
00350                         temp = *alpha * b[l + j * b_dim1];
00351                         i__3 = *m;
00352                         for (i = 1; i <= i__3; ++i) {
00353                             c[i + j * c_dim1] += temp * a[i + l * a_dim1];
00354 /* L70: */
00355                         }
00356                     }
00357 /* L80: */
00358                 }
00359 /* L90: */
00360             }
00361         } else {
00362 
00363 /*           Form  C := alpha*A'*B + beta*C */
00364 
00365             i__1 = *n;
00366             for (j = 1; j <= i__1; ++j) {
00367                 i__2 = *m;
00368                 for (i = 1; i <= i__2; ++i) {
00369                     temp = 0.;
00370                     i__3 = *k;
00371                     for (l = 1; l <= i__3; ++l) {
00372                         temp += a[l + i * a_dim1] * b[l + j * b_dim1];
00373 /* L100: */
00374                     }
00375                     if (*beta == 0.) {
00376                         c[i + j * c_dim1] = *alpha * temp;
00377                     } else {
00378                         c[i + j * c_dim1] = *alpha * temp + *beta * c[i + j * 
00379                                 c_dim1];
00380                     }
00381 /* L110: */
00382                 }
00383 /* L120: */
00384             }
00385         }
00386     } else {
00387         if (nota) {
00388 
00389 /*           Form  C := alpha*A*B' + beta*C */
00390 
00391             i__1 = *n;
00392             for (j = 1; j <= i__1; ++j) {
00393                 if (*beta == 0.) {
00394                     i__2 = *m;
00395                     for (i = 1; i <= i__2; ++i) {
00396                         c[i + j * c_dim1] = 0.;
00397 /* L130: */
00398                     }
00399                 } else if (*beta != 1.) {
00400                     i__2 = *m;
00401                     for (i = 1; i <= i__2; ++i) {
00402                         c[i + j * c_dim1] = *beta * c[i + j * c_dim1];
00403 /* L140: */
00404                     }
00405                 }
00406                 i__2 = *k;
00407                 for (l = 1; l <= i__2; ++l) {
00408                     if (b[j + l * b_dim1] != 0.) {
00409                         temp = *alpha * b[j + l * b_dim1];
00410                         i__3 = *m;
00411                         for (i = 1; i <= i__3; ++i) {
00412                             c[i + j * c_dim1] += temp * a[i + l * a_dim1];
00413 /* L150: */
00414                         }
00415                     }
00416 /* L160: */
00417                 }
00418 /* L170: */
00419             }
00420         } else {
00421 
00422 /*           Form  C := alpha*A'*B' + beta*C */
00423 
00424             i__1 = *n;
00425             for (j = 1; j <= i__1; ++j) {
00426                 i__2 = *m;
00427                 for (i = 1; i <= i__2; ++i) {
00428                     temp = 0.;
00429                     i__3 = *k;
00430                     for (l = 1; l <= i__3; ++l) {
00431                         temp += a[l + i * a_dim1] * b[j + l * b_dim1];
00432 /* L180: */
00433                     }
00434                     if (*beta == 0.) {
00435                         c[i + j * c_dim1] = *alpha * temp;
00436                     } else {
00437                         c[i + j * c_dim1] = *alpha * temp + *beta * c[i + j * 
00438                                 c_dim1];
00439                     }
00440 /* L190: */
00441                 }
00442 /* L200: */
00443             }
00444         }
00445     }
00446 
00447     return 0;
00448 
00449 /*     End of DGEMM . */
00450 
00451 } /* dgemm_ */
00452 

Generated on Wed Sep 5 12:54:19 2007 for DSACSS Operational Code by  doxygen 1.3.9.1