Strassen matrix-matrix multiply

DGEMMS/ZGEMMS

Actual character arguments in a subroutine call can be longer than the corresponding dummy arguments. Therefore, readability of the CALL statement can be improved, for example, by coding the transa and transb arguments as ’NORMAL’ or ’NONTRANS’ for ’N’, ’TRANSPOSE’ for ’T’, or ’CTRANS’ for ’C’. Refer to “Example 2.”

Example 1 Form the REAL*8 matrix product C = AB, where A is a 900-by-600 real matrix stored in an array A whose dimensions are 1000 by 1000, B is a 600-by-800 real matrix stored in an array B of dimension 1000 by 1000, and C is a 900-by-800 real matrix stored in an array C, also of dimension 1000 by 1000.

CHARACTER*1 TRANSA,TRANSB

INTEGER*4 M,N,K,LDA,LDB,LDC

REAL*8 ALPHA,BETA,A(1000,1000),B(1000,1000),

&C(1000,1000)

TRANSA = ’N’ TRANSB = ’N’ M = 900

N = 800 K = 600 ALPHA = 1.0 BETA = 0.0 LDA = 1000 LDB = 1000 LDC = 1000

CALL DGEMMS (TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,

&BETA,C,LDC)

Example 2 Form the COMPLEX*16 matrix product C 1C ρA B , where ρ is a complex = -- + *

2

scalar, A is a 600-by-900 complex matrix stored in an array A whose dimensions are 1000 by 1000, B is a 600-by-800 complex matrix stored in an array B of dimension 1000 by 1000, and C is a 900-by-800 complex matrix stored in an array C, also of dimension 1000 by 1000.

INTEGER*4 M,N,K,LDA,LDB,LDC

COMPLEX*16 RHO,A(1000,1000),B(1000,1000),C(1000,1000)

M = 900

N = 800

K = 600

LDA = 1000

LDB = 1000

LDC = 1000

CALL ZGEMMS (’CONJ’,’NORMAL’,M,N,K,RHO,A,LDA,B,LDB,

&(0.5D0,0.0D0),C,LDC)

Chapter 3 Basic Matrix Operations 231