- Matrix-matrix product and addition

{S,D,C,Z}GEMM(transa,transb,m,n,k,alpha,a,lda,b,ldb,beta,c,ldc)

transacharacter*1 On entry, specifies the form of (op)A used in the matrix multiplication: Iftransa= 'N' or 'n', (op)A = A Iftransa= 'T' or 't', (op)A = transp(A) Iftransa= 'R' or 'r', (op)A = conjugate(A) Iftransa= 'C' or 'c', (op)A = conjug_transp(A) On exit,transais unchanged.transbcharacter*1 On entry, specifies the form of (op)B used in the matrix multiplication: Iftransb= 'N' or 'n', (op)B = B Iftransb= 'T' or 't', (op)B = transp(B) Iftransb= 'R' or 'r', (op)B = conjugate(B) Iftransb= 'C' or 'c', (op)B = conjug_transp(B)minteger*4 On entry, the number of rows of the matrix (op)A and of the matrix C; m >= 0 On exit,mis unchanged.ninteger*4 On entry, the number of columns of the matrix (op)B and of the matrix C; n >= 0 On exit,nis unchanged.kinteger*4 On entry, the number of columns of the matrix (op)A and the number of rows of the matrix (op)B; k >= 0 On exit,kis unchanged.alphareal*4 | real*8 | complex*8 | complex*16 On entry, specifies the scalar alpha. On exit,alphais unchanged.areal*4 | real*8 | complex*8 | complex*16 On entry, a two-dimensional array A with dimensions lda by ka. For (op)A = A or conjugate(A), ka >= k and the leading m by k portion of the array A contains the matrix A. For (op)A = transp(A) or conjug_transp(A), ka >= m and the leading k by m part of the array A contains the matrix A. On exit,ais unchanged.ldainteger*4 On entry, the first dimension of array A. For (op)A = A or conjugate(A), lda >= MAX(1,m). For (op)A = transp(A) or conjug_transp(A), lda >= MAX(1,k). On exit,ldais unchanged.breal*4 | real*8 | complex*8 | complex*16 On entry, a two-dimensional array B with dimensions ldb by kb. For (op)B = B or conjugate(B), kb >= n and the leading k by n portion of the array contains the matrix B. For (op)B = transp(B) or conjug_transp(B), kb >= k and the leading n by k part of the array contains the matrix B. On exit,bis unchanged.ldbinteger*4 On entry, the first dimension of array B. For (op)B = B or <conjugate(B), ldb >= MAX(1,k). For (op)B = transp(B) or conjug_transp(B), ldb >= MAX(1,n). On exit,ldbis unchanged.betareal*4 | real*8 | complex*8 | complex*16 On entry, specifies the scalar beta. On exit,betais unchanged.creal*4 | real*8 | complex*8 | complex*16 On entry, a two-dimensional array with the dimension ldc by at least n. On exit, the leading m by n part of array C is overwritten by the matrix alpha*(op)A*(op)B + beta*C.ldcinteger*4 On entry, the first dimension of array C; ldc >= MAX(1,m) On exit,ldcis unchanged.

The _GEMM routines perform the following operations: C = alpha(op)A(op)B + beta*C where (op)(X) = X, transp(X), conjugate(X), or conjug_transp(X), alpha and beta are scalars, and A, B, and C are matrices. (op)A is an m by k matrix, (op)B is a k by n matrix, and C is an m by n matrix.

REAL*4 A(20,40), B(20,30), C(40,30), alpha, beta M = 10 N = 20 K = 15 LDA = 20 LDB = 20 LDC = 40 alpha = 2.0 beta = 2.0 CALL SGEMM ('T','N',M,N,K,alpha,A,LDA,B,LDB,beta,C,LDC) This FORTRAN code computes the product C = alpha * transp(A)*B + beta*C where A is a real general matrix. A is a 15 by 10 real general matrix embedded in array A. B is a 15 by 20 real general matrix embedded in array B. C is a 10 by 20 real general matrix embedded in array C.