c@427: /* dgemm.f -- translated by f2c (version 20061008). c@427: You must link the resulting object file with libf2c: c@427: on Microsoft Windows system, link with libf2c.lib; c@427: on Linux or Unix systems, link with .../path/to/libf2c.a -lm c@427: or, if you install libf2c.a in a standard place, with -lf2c -lm c@427: -- in that order, at the end of the command line, as in c@427: cc *.o -lf2c -lm c@427: Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., c@427: c@427: http://www.netlib.org/f2c/libf2c.zip c@427: */ c@427: c@427: #include "f2c.h" c@427: #include "blaswrap.h" c@427: c@427: /* Subroutine */ int dgemm_(char *transa, char *transb, integer *m, integer * c@427: n, integer *k, doublereal *alpha, doublereal *a, integer *lda, c@427: doublereal *b, integer *ldb, doublereal *beta, doublereal *c__, c@427: integer *ldc) c@427: { c@427: /* System generated locals */ c@427: integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2, c@427: i__3; c@427: c@427: /* Local variables */ c@427: integer i__, j, l, info; c@427: logical nota, notb; c@427: doublereal temp; c@427: integer ncola; c@427: extern logical lsame_(char *, char *); c@427: integer nrowa, nrowb; c@427: extern /* Subroutine */ int xerbla_(char *, integer *); c@427: c@427: /* .. Scalar Arguments .. */ c@427: /* .. */ c@427: /* .. Array Arguments .. */ c@427: /* .. */ c@427: c@427: /* Purpose */ c@427: /* ======= */ c@427: c@427: /* DGEMM performs one of the matrix-matrix operations */ c@427: c@427: /* C := alpha*op( A )*op( B ) + beta*C, */ c@427: c@427: /* where op( X ) is one of */ c@427: c@427: /* op( X ) = X or op( X ) = X', */ c@427: c@427: /* alpha and beta are scalars, and A, B and C are matrices, with op( A ) */ c@427: /* an m by k matrix, op( B ) a k by n matrix and C an m by n matrix. */ c@427: c@427: /* Arguments */ c@427: /* ========== */ c@427: c@427: /* TRANSA - CHARACTER*1. */ c@427: /* On entry, TRANSA specifies the form of op( A ) to be used in */ c@427: /* the matrix multiplication as follows: */ c@427: c@427: /* TRANSA = 'N' or 'n', op( A ) = A. */ c@427: c@427: /* TRANSA = 'T' or 't', op( A ) = A'. */ c@427: c@427: /* TRANSA = 'C' or 'c', op( A ) = A'. */ c@427: c@427: /* Unchanged on exit. */ c@427: c@427: /* TRANSB - CHARACTER*1. */ c@427: /* On entry, TRANSB specifies the form of op( B ) to be used in */ c@427: /* the matrix multiplication as follows: */ c@427: c@427: /* TRANSB = 'N' or 'n', op( B ) = B. */ c@427: c@427: /* TRANSB = 'T' or 't', op( B ) = B'. */ c@427: c@427: /* TRANSB = 'C' or 'c', op( B ) = B'. */ c@427: c@427: /* Unchanged on exit. */ c@427: c@427: /* M - INTEGER. */ c@427: /* On entry, M specifies the number of rows of the matrix */ c@427: /* op( A ) and of the matrix C. M must be at least zero. */ c@427: /* Unchanged on exit. */ c@427: c@427: /* N - INTEGER. */ c@427: /* On entry, N specifies the number of columns of the matrix */ c@427: /* op( B ) and the number of columns of the matrix C. N must be */ c@427: /* at least zero. */ c@427: /* Unchanged on exit. */ c@427: c@427: /* K - INTEGER. */ c@427: /* On entry, K specifies the number of columns of the matrix */ c@427: /* op( A ) and the number of rows of the matrix op( B ). K must */ c@427: /* be at least zero. */ c@427: /* Unchanged on exit. */ c@427: c@427: /* ALPHA - DOUBLE PRECISION. */ c@427: /* On entry, ALPHA specifies the scalar alpha. */ c@427: /* Unchanged on exit. */ c@427: c@427: /* A - DOUBLE PRECISION array of DIMENSION ( LDA, ka ), where ka is */ c@427: /* k when TRANSA = 'N' or 'n', and is m otherwise. */ c@427: /* Before entry with TRANSA = 'N' or 'n', the leading m by k */ c@427: /* part of the array A must contain the matrix A, otherwise */ c@427: /* the leading k by m part of the array A must contain the */ c@427: /* matrix A. */ c@427: /* Unchanged on exit. */ c@427: c@427: /* LDA - INTEGER. */ c@427: /* On entry, LDA specifies the first dimension of A as declared */ c@427: /* in the calling (sub) program. When TRANSA = 'N' or 'n' then */ c@427: /* LDA must be at least max( 1, m ), otherwise LDA must be at */ c@427: /* least max( 1, k ). */ c@427: /* Unchanged on exit. */ c@427: c@427: /* B - DOUBLE PRECISION array of DIMENSION ( LDB, kb ), where kb is */ c@427: /* n when TRANSB = 'N' or 'n', and is k otherwise. */ c@427: /* Before entry with TRANSB = 'N' or 'n', the leading k by n */ c@427: /* part of the array B must contain the matrix B, otherwise */ c@427: /* the leading n by k part of the array B must contain the */ c@427: /* matrix B. */ c@427: /* Unchanged on exit. */ c@427: c@427: /* LDB - INTEGER. */ c@427: /* On entry, LDB specifies the first dimension of B as declared */ c@427: /* in the calling (sub) program. When TRANSB = 'N' or 'n' then */ c@427: /* LDB must be at least max( 1, k ), otherwise LDB must be at */ c@427: /* least max( 1, n ). */ c@427: /* Unchanged on exit. */ c@427: c@427: /* BETA - DOUBLE PRECISION. */ c@427: /* On entry, BETA specifies the scalar beta. When BETA is */ c@427: /* supplied as zero then C need not be set on input. */ c@427: /* Unchanged on exit. */ c@427: c@427: /* C - DOUBLE PRECISION array of DIMENSION ( LDC, n ). */ c@427: /* Before entry, the leading m by n part of the array C must */ c@427: /* contain the matrix C, except when beta is zero, in which */ c@427: /* case C need not be set on entry. */ c@427: /* On exit, the array C is overwritten by the m by n matrix */ c@427: /* ( alpha*op( A )*op( B ) + beta*C ). */ c@427: c@427: /* LDC - INTEGER. */ c@427: /* On entry, LDC specifies the first dimension of C as declared */ c@427: /* in the calling (sub) program. LDC must be at least */ c@427: /* max( 1, m ). */ c@427: /* Unchanged on exit. */ c@427: c@427: c@427: /* Level 3 Blas routine. */ c@427: c@427: /* -- Written on 8-February-1989. */ c@427: /* Jack Dongarra, Argonne National Laboratory. */ c@427: /* Iain Duff, AERE Harwell. */ c@427: /* Jeremy Du Croz, Numerical Algorithms Group Ltd. */ c@427: /* Sven Hammarling, Numerical Algorithms Group Ltd. */ c@427: c@427: c@427: /* .. External Functions .. */ c@427: /* .. */ c@427: /* .. External Subroutines .. */ c@427: /* .. */ c@427: /* .. Intrinsic Functions .. */ c@427: /* .. */ c@427: /* .. Local Scalars .. */ c@427: /* .. */ c@427: /* .. Parameters .. */ c@427: /* .. */ c@427: c@427: /* Set NOTA and NOTB as true if A and B respectively are not */ c@427: /* transposed and set NROWA, NCOLA and NROWB as the number of rows */ c@427: /* and columns of A and the number of rows of B respectively. */ c@427: c@427: /* Parameter adjustments */ c@427: a_dim1 = *lda; c@427: a_offset = 1 + a_dim1; c@427: a -= a_offset; c@427: b_dim1 = *ldb; c@427: b_offset = 1 + b_dim1; c@427: b -= b_offset; c@427: c_dim1 = *ldc; c@427: c_offset = 1 + c_dim1; c@427: c__ -= c_offset; c@427: c@427: /* Function Body */ c@427: nota = lsame_(transa, "N"); c@427: notb = lsame_(transb, "N"); c@427: if (nota) { c@427: nrowa = *m; c@427: ncola = *k; c@427: } else { c@427: nrowa = *k; c@427: ncola = *m; c@427: } c@427: if (notb) { c@427: nrowb = *k; c@427: } else { c@427: nrowb = *n; c@427: } c@427: c@427: /* Test the input parameters. */ c@427: c@427: info = 0; c@427: if (! nota && ! lsame_(transa, "C") && ! lsame_( c@427: transa, "T")) { c@427: info = 1; c@427: } else if (! notb && ! lsame_(transb, "C") && ! c@427: lsame_(transb, "T")) { c@427: info = 2; c@427: } else if (*m < 0) { c@427: info = 3; c@427: } else if (*n < 0) { c@427: info = 4; c@427: } else if (*k < 0) { c@427: info = 5; c@427: } else if (*lda < max(1,nrowa)) { c@427: info = 8; c@427: } else if (*ldb < max(1,nrowb)) { c@427: info = 10; c@427: } else if (*ldc < max(1,*m)) { c@427: info = 13; c@427: } c@427: if (info != 0) { c@427: xerbla_("DGEMM ", &info); c@427: return 0; c@427: } c@427: c@427: /* Quick return if possible. */ c@427: c@427: if (*m == 0 || *n == 0 || (*alpha == 0. || *k == 0) && *beta == 1.) { c@427: return 0; c@427: } c@427: c@427: /* And if alpha.eq.zero. */ c@427: c@427: if (*alpha == 0.) { c@427: if (*beta == 0.) { c@427: i__1 = *n; c@427: for (j = 1; j <= i__1; ++j) { c@427: i__2 = *m; c@427: for (i__ = 1; i__ <= i__2; ++i__) { c@427: c__[i__ + j * c_dim1] = 0.; c@427: /* L10: */ c@427: } c@427: /* L20: */ c@427: } c@427: } else { c@427: i__1 = *n; c@427: for (j = 1; j <= i__1; ++j) { c@427: i__2 = *m; c@427: for (i__ = 1; i__ <= i__2; ++i__) { c@427: c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1]; c@427: /* L30: */ c@427: } c@427: /* L40: */ c@427: } c@427: } c@427: return 0; c@427: } c@427: c@427: /* Start the operations. */ c@427: c@427: if (notb) { c@427: if (nota) { c@427: c@427: /* Form C := alpha*A*B + beta*C. */ c@427: c@427: i__1 = *n; c@427: for (j = 1; j <= i__1; ++j) { c@427: if (*beta == 0.) { c@427: i__2 = *m; c@427: for (i__ = 1; i__ <= i__2; ++i__) { c@427: c__[i__ + j * c_dim1] = 0.; c@427: /* L50: */ c@427: } c@427: } else if (*beta != 1.) { c@427: i__2 = *m; c@427: for (i__ = 1; i__ <= i__2; ++i__) { c@427: c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1]; c@427: /* L60: */ c@427: } c@427: } c@427: i__2 = *k; c@427: for (l = 1; l <= i__2; ++l) { c@427: if (b[l + j * b_dim1] != 0.) { c@427: temp = *alpha * b[l + j * b_dim1]; c@427: i__3 = *m; c@427: for (i__ = 1; i__ <= i__3; ++i__) { c@427: c__[i__ + j * c_dim1] += temp * a[i__ + l * c@427: a_dim1]; c@427: /* L70: */ c@427: } c@427: } c@427: /* L80: */ c@427: } c@427: /* L90: */ c@427: } c@427: } else { c@427: c@427: /* Form C := alpha*A'*B + beta*C */ c@427: c@427: i__1 = *n; c@427: for (j = 1; j <= i__1; ++j) { c@427: i__2 = *m; c@427: for (i__ = 1; i__ <= i__2; ++i__) { c@427: temp = 0.; c@427: i__3 = *k; c@427: for (l = 1; l <= i__3; ++l) { c@427: temp += a[l + i__ * a_dim1] * b[l + j * b_dim1]; c@427: /* L100: */ c@427: } c@427: if (*beta == 0.) { c@427: c__[i__ + j * c_dim1] = *alpha * temp; c@427: } else { c@427: c__[i__ + j * c_dim1] = *alpha * temp + *beta * c__[ c@427: i__ + j * c_dim1]; c@427: } c@427: /* L110: */ c@427: } c@427: /* L120: */ c@427: } c@427: } c@427: } else { c@427: if (nota) { c@427: c@427: /* Form C := alpha*A*B' + beta*C */ c@427: c@427: i__1 = *n; c@427: for (j = 1; j <= i__1; ++j) { c@427: if (*beta == 0.) { c@427: i__2 = *m; c@427: for (i__ = 1; i__ <= i__2; ++i__) { c@427: c__[i__ + j * c_dim1] = 0.; c@427: /* L130: */ c@427: } c@427: } else if (*beta != 1.) { c@427: i__2 = *m; c@427: for (i__ = 1; i__ <= i__2; ++i__) { c@427: c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1]; c@427: /* L140: */ c@427: } c@427: } c@427: i__2 = *k; c@427: for (l = 1; l <= i__2; ++l) { c@427: if (b[j + l * b_dim1] != 0.) { c@427: temp = *alpha * b[j + l * b_dim1]; c@427: i__3 = *m; c@427: for (i__ = 1; i__ <= i__3; ++i__) { c@427: c__[i__ + j * c_dim1] += temp * a[i__ + l * c@427: a_dim1]; c@427: /* L150: */ c@427: } c@427: } c@427: /* L160: */ c@427: } c@427: /* L170: */ c@427: } c@427: } else { c@427: c@427: /* Form C := alpha*A'*B' + beta*C */ c@427: c@427: i__1 = *n; c@427: for (j = 1; j <= i__1; ++j) { c@427: i__2 = *m; c@427: for (i__ = 1; i__ <= i__2; ++i__) { c@427: temp = 0.; c@427: i__3 = *k; c@427: for (l = 1; l <= i__3; ++l) { c@427: temp += a[l + i__ * a_dim1] * b[j + l * b_dim1]; c@427: /* L180: */ c@427: } c@427: if (*beta == 0.) { c@427: c__[i__ + j * c_dim1] = *alpha * temp; c@427: } else { c@427: c__[i__ + j * c_dim1] = *alpha * temp + *beta * c__[ c@427: i__ + j * c_dim1]; c@427: } c@427: /* L190: */ c@427: } c@427: /* L200: */ c@427: } c@427: } c@427: } c@427: c@427: return 0; c@427: c@427: /* End of DGEMM . */ c@427: c@427: } /* dgemm_ */