subroutine sgemm ( transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc ) ! !******************************************************************************* ! !! SGEMM performs one of the matrix-matrix operations ! ! c := alpha*op( a )*op( b ) + beta*c, ! ! where op( x ) is one of ! ! op( x ) = x or op( x ) = x', ! ! alpha and beta are scalars, and a, b and c are matrices, with op( a ) ! an m by k matrix, op( b ) a k by n matrix and c an m by n matrix. ! ! Parameters: ! ! transa - character. ! on entry, transa specifies the form of op( a ) to be used in ! the matrix multiplication as follows: ! ! transa = 'n' or 'N', op( a ) = a. ! ! transa = 't' or 'T', op( a ) = a'. ! ! transa = 'c' or 'C', op( a ) = a'. ! ! unchanged on exit. ! ! transb - character. ! on entry, transb specifies the form of op( b ) to be used in ! the matrix multiplication as follows: ! ! transb = 'n' or 'N', op( b ) = b. ! ! transb = 't' or 'T', op( b ) = b'. ! ! transb = 'c' or 'C', op( b ) = b'. ! ! unchanged on exit. ! ! m - integer. ! on entry, m specifies the number of rows of the matrix ! op( a ) and of the matrix c. m must be at least 0. ! unchanged on exit. ! ! n - integer. ! on entry, n specifies the number of columns of the matrix ! op( b ) and the number of columns of the matrix c. n must be ! at least 0. ! unchanged on exit. ! ! k - integer. ! on entry, k specifies the number of columns of the matrix ! op( a ) and the number of rows of the matrix op( b ). k must ! be at least 0. ! unchanged on exit. ! ! alpha - real . ! on entry, alpha specifies the scalar alpha. ! unchanged on exit. ! ! a - real array of dimension ( lda, ka ), where ka is ! k when transa = 'n' or 'N', and is m otherwise. ! before entry with transa = 'n' or 'N', the leading m by k ! part of the array a must contain the matrix a, otherwise ! the leading k by m part of the array a must contain the ! matrix a. ! unchanged on exit. ! ! lda - integer. ! on entry, lda specifies the first dimension of a as declared ! in the calling (sub) program. when transa = 'n' or 'N' then ! lda must be at least max( 1, m ), otherwise lda must be at ! least max( 1, k ). ! unchanged on exit. ! ! b - real array of dimension ( ldb, kb ), where kb is ! n when transb = 'n' or 'N', and is k otherwise. ! before entry with transb = 'n' or 'N', the leading k by n ! part of the array b must contain the matrix b, otherwise ! the leading n by k part of the array b must contain the ! matrix b. ! unchanged on exit. ! ! ldb - integer. ! on entry, ldb specifies the first dimension of b as declared ! in the calling (sub) program. when transb = 'n' or 'N' then ! ldb must be at least max( 1, k ), otherwise ldb must be at ! least max( 1, n ). ! unchanged on exit. ! ! beta - real . ! on entry, beta specifies the scalar beta. when beta is ! supplied as 0.0 then c need not be set on input. ! unchanged on exit. ! ! c - real array of dimension ( ldc, n ). ! before entry, the leading m by n part of the array c must ! contain the matrix c, except when beta is 0.0, in which ! case c need not be set on entry. ! on exit, the array c is overwritten by the m by n matrix ! ( alpha*op( a )*op( b ) + beta*c ). ! ! ldc - integer. ! on entry, ldc specifies the first dimension of c as declared ! in the calling (sub) program. ldc must be at least ! max( 1, m ). ! unchanged on exit. ! ! ! level 3 blas routine. ! ! -- written on 8-february-1989. ! jack dongarra, argonne national laboratory. ! iain duff, aere harwell. ! jeremy du croz, numerical algorithms group ltd. ! sven hammarling, numerical algorithms group ltd. ! character transa, transb integer m, n, k, lda, ldb, ldc real alpha, beta ! .. array arguments .. real a( lda, * ), b( ldb, * ), c( ldc, * ) ! .. ! .. external functions .. logical lsame external lsame ! .. external subroutines .. external xerbla ! .. intrinsic functions .. intrinsic max ! .. local scalars .. logical nota, notb integer i, info, j, l, ncola, nrowa, nrowb real temp ! ! set nota and notb as true if a and b respectively are not ! transposed and set nrowa, ncola and nrowb as the number of rows ! and columns of a and the number of rows of b respectively. ! nota = lsame( transa, 'N' ) notb = lsame( transb, 'N' ) if ( nota ) then nrowa = m ncola = k else nrowa = k ncola = m end if if ( notb ) then nrowb = k else nrowb = n end if ! ! test the input parameters. ! info = 0 if ( ( .not.nota ).and. & ( .not.lsame( transa, 'C' ) ).and. & ( .not.lsame( transa, 'T' ) ) ) then info = 1 else if ( ( .not.notb ).and. & ( .not.lsame( transb, 'C' ) ).and. & ( .not.lsame( transb, 'T' ) ) ) then info = 2 else if ( m <0 ) then info = 3 else if ( n <0 ) then info = 4 else if ( k <0 ) then info = 5 else if ( lda