gemm(3)
π gemm(3) π
okay bestie, welcome to the gemm(3) page from the Library Functions Manual β yes the whole thing is literally called gemm, and it's giving main character energy in the BLAS cinematic universe π
β¨ NAME β¨
gemm β gemm: general matrix-matrix multiply π₯
πΈ SYNOPSIS πΈ
π«Ά Functions π«Ά
subroutine cgemm (transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)β CGEMM πsubroutine dgemm (transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)β DGEMM πsubroutine sgemm (transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)β SGEMM πsubroutine zgemm (transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)β ZGEMM π
π Detailed Description π
this part is just vibes β the actual tea is in Function Documentation right below, so keep scrolling π§
π¦ Function Documentation π¦
π subroutine cgemm (character transa, character transb, integer m, integer n, integer k, complex alpha, complex, dimension(lda,*) a, integer lda, complex, dimension(ldb,*) b, integer ldb, complex beta, complex, dimension(ldc,*) c, integer ldc)
β CGEMM β
π Purpose: π
okay so CGEMM performs one of the matrix-matrix operations, and it's literally this:
C := alpha*op( A )*op( B ) + beta*C,
where op( X ) is one of
op( X ) = X or op( X ) = X**T or op( X ) = X**H,
and 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. no cap, that's the whole bit π«Ά
π Parameters π
TRANSAβTRANSAisCHARACTER*1. on entry,TRANSAspecifies the form ofop( A )to be used in the matrix multiplication, like this:TRANSA = 'N' or 'n',op( A ) = A.TRANSA = 'T' or 't',op( A ) = A**T.TRANSA = 'C' or 'c',op( A ) = A**H.
TRANSBβTRANSBisCHARACTER*1. on entry,TRANSBspecifies the form ofop( B )to be used in the matrix multiplication, like this:TRANSB = 'N' or 'n',op( B ) = B.TRANSB = 'T' or 't',op( B ) = B**T.TRANSB = 'C' or 'c',op( B ) = B**H.
MβMisINTEGER. on entry,Mspecifies the number of rows of the matrixop( A )and of the matrixC.Mmust be at least zero. lowkey non-negotiable π«NβNisINTEGER. on entry,Nspecifies the number of columns of the matrixop( B )and the number of columns of the matrixC.Nmust be at least zero.KβKisINTEGER. on entry,Kspecifies the number of columns of the matrixop( A )and the number of rows of the matrixop( B ).Kmust be at least zero.ALPHAβALPHAisCOMPLEX. on entry,ALPHAspecifies the scalaralpha.AβAisCOMPLEXarray, dimension( LDA, ka ), wherekaiskwhenTRANSA = 'N' or 'n', and ismotherwise. before entry withTRANSA = 'N' or 'n', the leading m by k part of the arrayAmust contain the matrixA, otherwise the leading k by m part of the arrayAmust contain the matrixA. the way this array reshapes itself depending onTRANSA?? iconic π¦LDAβLDAisINTEGER. on entry,LDAspecifies the first dimension ofAas declared in the calling (sub) program. whenTRANSA = 'N' or 'n'thenLDAmust be at leastmax( 1, m ), otherwiseLDAmust be at leastmax( 1, k ).BβBisCOMPLEXarray, dimension( LDB, kb ), wherekbisnwhenTRANSB = 'N' or 'n', and iskotherwise. before entry withTRANSB = 'N' or 'n', the leading k by n part of the arrayBmust contain the matrixB, otherwise the leading n by k part of the arrayBmust contain the matrixB.LDBβLDBisINTEGER. on entry,LDBspecifies the first dimension ofBas declared in the calling (sub) program. whenTRANSB = 'N' or 'n'thenLDBmust be at leastmax( 1, k ), otherwiseLDBmust be at leastmax( 1, n ).BETAβBETAisCOMPLEX. on entry,BETAspecifies the scalarbeta. whenBETAis supplied as zero thenCneed not be set on input. free real estate, we love a shortcut πCβCisCOMPLEXarray, dimension( LDC, N ). before entry, the leading m by n part of the arrayCmust contain the matrixC, except whenbetais zero, in which caseCneed not be set on entry. on exit, the arrayCis overwritten by the m by n matrix( alpha*op( A )*op( B ) + beta*C ). β οΈ she gets overwritten, so don't come crying when your oldCis gone fr fr.LDCβLDCisINTEGER. on entry,LDCspecifies the first dimension ofCas declared in the calling (sub) program.LDCmust be at leastmax( 1, m ).
π Author π
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
π Further Details: π
- 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.
Definition at line 186 of file cgemm.f.
π subroutine dgemm (character transa, character transb, integer m, integer n, integer k, double precision alpha, double precision, dimension(lda,*) a, integer lda, double precision, dimension(ldb,*) b, integer ldb, double precision beta, double precision, dimension(ldc,*) c, integer ldc)
β DGEMM β
π Purpose: π
DGEMM performs one of the matrix-matrix operations, and it's literally this:
C := alpha*op( A )*op( B ) + beta*C,
where op( X ) is one of
op( X ) = X or op( X ) = X**T,
and 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. π«Ά
heads up bestie: double precisionDGEMMlists onlyXandX**Tin itsop( X )lineup β noX**Hin this one. the conjugate stays with the complex girls π
π Parameters π
TRANSAβTRANSAisCHARACTER*1. on entry,TRANSAspecifies the form ofop( A )to be used in the matrix multiplication, like this:TRANSA = 'N' or 'n',op( A ) = A.TRANSA = 'T' or 't',op( A ) = A**T.TRANSA = 'C' or 'c',op( A ) = A**T.
TRANSBβTRANSBisCHARACTER*1. on entry,TRANSBspecifies the form ofop( B )to be used in the matrix multiplication, like this:TRANSB = 'N' or 'n',op( B ) = B.TRANSB = 'T' or 't',op( B ) = B**T.TRANSB = 'C' or 'c',op( B ) = B**T.
MβMisINTEGER. on entry,Mspecifies the number of rows of the matrixop( A )and of the matrixC.Mmust be at least zero.NβNisINTEGER. on entry,Nspecifies the number of columns of the matrixop( B )and the number of columns of the matrixC.Nmust be at least zero.KβKisINTEGER. on entry,Kspecifies the number of columns of the matrixop( A )and the number of rows of the matrixop( B ).Kmust be at least zero.ALPHAβALPHAisDOUBLE PRECISION. on entry,ALPHAspecifies the scalaralpha.AβAisDOUBLE PRECISIONarray, dimension( LDA, ka ), wherekaiskwhenTRANSA = 'N' or 'n', and ismotherwise. before entry withTRANSA = 'N' or 'n', the leading m by k part of the arrayAmust contain the matrixA, otherwise the leading k by m part of the arrayAmust contain the matrixA.LDAβLDAisINTEGER. on entry,LDAspecifies the first dimension ofAas declared in the calling (sub) program. whenTRANSA = 'N' or 'n'thenLDAmust be at leastmax( 1, m ), otherwiseLDAmust be at leastmax( 1, k ).BβBisDOUBLE PRECISIONarray, dimension( LDB, kb ), wherekbisnwhenTRANSB = 'N' or 'n', and iskotherwise. before entry withTRANSB = 'N' or 'n', the leading k by n part of the arrayBmust contain the matrixB, otherwise the leading n by k part of the arrayBmust contain the matrixB.LDBβLDBisINTEGER. on entry,LDBspecifies the first dimension ofBas declared in the calling (sub) program. whenTRANSB = 'N' or 'n'thenLDBmust be at leastmax( 1, k ), otherwiseLDBmust be at leastmax( 1, n ).BETAβBETAisDOUBLE PRECISION. on entry,BETAspecifies the scalarbeta. whenBETAis supplied as zero thenCneed not be set on input. πCβCisDOUBLE PRECISIONarray, dimension( LDC, N ). before entry, the leading m by n part of the arrayCmust contain the matrixC, except whenbetais zero, in which caseCneed not be set on entry. on exit, the arrayCis overwritten by the m by n matrix( alpha*op( A )*op( B ) + beta*C ). β οΈ again: overwritten, so screenshot yourCbefore you call this, iykyk.LDCβLDCisINTEGER. on entry,LDCspecifies the first dimension ofCas declared in the calling (sub) program.LDCmust be at leastmax( 1, m ).
π Author π
- Univ. of Tennessee
β¦and that's where part 1 leaves us, mid-author-list, on a cliffhanger π« more is literally coming π
π Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
π«Ά Further Details
Like, here's the receipts, bestie β the original header comment, verbatim:
!>
!> 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.
!>
So yeah β Level 3 Blas routine, written on 8-February-1989 by Jack Dongarra (Argonne National Laboratory), Iain Duff (AERE Harwell), Jeremy Du Croz (Numerical Algorithms Group Ltd.) and Sven Hammarling (Numerical Algorithms Group Ltd.). Legends. Periodt. π
Definition at line 186 of file dgemm.f.
π¦ subroutine sgemm (character transa, character transb, integer m, integer n, integer k, real alpha, real, dimension(lda,) a, integer lda, real, dimension(ldb,) b, integer ldb, real beta, real, dimension(ldc,*) c, integer ldc)
subroutine sgemm (character transa, character transb, integer m, integer n,
integer k, real alpha, real, dimension(lda,*) a, integer lda, real,
dimension(ldb,*) b, integer ldb, real beta, real, dimension(ldc,*) c,
integer ldc)
SGEMM π
β¨ Purpose
Okay so 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**T,
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. It's giving "the" matmul, fr fr. π₯
π₯ Parameters
TRANSAβTRANSA is CHARACTER*1. On entry,TRANSAspecifies the form ofop( A )to be used in the matrix multiplication, as follows:TRANSA = 'N' or 'n',op( A ) = A.TRANSA = 'T' or 't',op( A ) = A**T.TRANSA = 'C' or 'c',op( A ) = A**T.
TRANSBβTRANSB is CHARACTER*1. On entry,TRANSBspecifies the form ofop( B )to be used in the matrix multiplication, as follows:TRANSB = 'N' or 'n',op( B ) = B.TRANSB = 'T' or 't',op( B ) = B**T.TRANSB = 'C' or 'c',op( B ) = B**T.
Not me pointing out that for this real version,'C'gives you the exact same thing as'T'β both areA**T/B**Tup there. That's literally what the page says, don't come for me. π
MβM is INTEGER. On entry,Mspecifies the number of rows of the matrixop( A )and of the matrixC.Mmust be at least zero. Zero is a valid vibe, apparently. πNβN is INTEGER. On entry,Nspecifies the number of columns of the matrixop( B )and the number of columns of the matrixC.Nmust be at least zero.KβK is INTEGER. On entry,Kspecifies the number of columns of the matrixop( A )and the number of rows of the matrixop( B ).Kmust be at least zero.ALPHAβALPHA is REAL. On entry,ALPHAspecifies the scalar alpha. Just a little guy. πAβA is REAL array, dimension ( LDA, ka ), wherekaiskwhenTRANSA = 'N' or 'n', and ismotherwise. Before entry withTRANSA = 'N' or 'n', the leading m by k part of the arrayAmust contain the matrixA, otherwise the leading k by m part of the arrayAmust contain the matrixA. Yes, that's the shape-swap, iykyk.LDAβLDA is INTEGER. On entry,LDAspecifies the first dimension ofAas declared in the calling (sub) program. WhenTRANSA = 'N' or 'n'thenLDAmust be at leastmax( 1, m ), otherwiseLDAmust be at leastmax( 1, k ). Thatmax( 1, ... )is doing the Lord's work, don't skip it.BβB is REAL array, dimension ( LDB, kb ), wherekbisnwhenTRANSB = 'N' or 'n', and iskotherwise. Before entry withTRANSB = 'N' or 'n', the leading k by n part of the arrayBmust contain the matrixB, otherwise the leading n by k part of the arrayBmust contain the matrixB.LDBβLDB is INTEGER. On entry,LDBspecifies the first dimension ofBas declared in the calling (sub) program. WhenTRANSB = 'N' or 'n'thenLDBmust be at leastmax( 1, k ), otherwiseLDBmust be at leastmax( 1, n ).BETAβBETA is REAL. On entry,BETAspecifies the scalar beta. WhenBETAis supplied as zero thenCneed not be set on input. Big slay β you literally don't have to initializeCin that case, the routine's not even gonna look. π§CβC is REAL array, dimension ( LDC, N ). Before entry, the leading m by n part of the arrayCmust contain the matrixC, except whenbetais zero, in which caseCneed not be set on entry. On exit, the arrayCis overwritten by the m by n matrix( alpha*op( A )*op( B ) + beta*C ).
β οΈ Overwritten.Ccomes in as your matrix and leaves as the answer β it's the main character of this whole page, and it does NOT get to keep its old self. If you still needed the originalC, copy it first. π
LDCβLDC is INTEGER. On entry,LDCspecifies the first dimension ofCas declared in the calling (sub) program.LDCmust be at leastmax( 1, m ).
π Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
π Further Details
Same iconique header comment, bestie:
!>
!> 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.
!>
Level 3 Blas routine, written on 8-February-1989 by Jack Dongarra (Argonne National Laboratory), Iain Duff (AERE Harwell), Jeremy Du Croz (Numerical Algorithms Group Ltd.) and Sven Hammarling (Numerical Algorithms Group Ltd.). Same squad, single precision this time. π
Definition at line 186 of file sgemm.f.
π§ subroutine zgemm (character transa, character transb, integer m, integer n, integer k, complex*16 alpha, complex*16, dimension(lda,) a, integer lda, complex16, dimension(ldb,) b, integer ldb, complex16 beta, complex*16, dimension(ldc,*) c, integer ldc)
subroutine zgemm (character transa, character transb, integer m, integer n,
integer k, complex*16 alpha, complex*16, dimension(lda,*) a, integer
lda, complex*16, dimension(ldb,*) b, integer ldb, complex*16 beta,
complex*16, dimension(ldc,*) c, integer ldc)
ZGEMM π
β Purpose
ZGEMM 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**T or op( X ) = X**H,
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. And yes β X**H is in the building here, that's the conjugate-transpose upgrade, we're in complex land now. π¦
π« Parameters
TRANSAβTRANSA is CHARACTER*1. On entry,TRANSAspecifies the form ofop( A )to be used in the matrix multiplication, as follows:TRANSA = 'N' or 'n',op( A ) = A.TRANSA = 'T' or 't',op( A ) = A**T.TRANSA = 'C' or 'c',op( A ) = A**H.
β οΈ Careful, bestie: for ZGEMM,'C'meansA**Hβ conjugate transpose β not plainA**T. That's a whole different vibe from the real-precision versions up the page. π
TRANSBβTRANSB is CHARACTER*1. On entry,TRANSBspecifies the form ofop( B )to be used in the matrix multiplication, as follows:TRANSB = 'N' or 'n',op( B ) = B.TRANSB = 'T' or 't',op( B ) = B**T.TRANSB = 'C' or 'c',op( B ) = B**H.
MβM is INTEGER. On entry,Mspecifies the number of rows of the matrixop( A )and of the matrixC.Mmust be at least zero.NβN is INTEGER. On entry,Nspecifies the number of columns of the matrixop( B )and the number of columns of the matrixC.Nmust be at least zero.KβK is INTEGER. On entry,Kspecifies the number of columns of the matrixop( A )and the number of rows of the matrixop( B ).Kmust be at least zero.ALPHAβALPHA is COMPLEX*16. On entry,ALPHAspecifies the scalar alpha.AβA is COMPLEX*16 array, dimension ( LDA, ka ), wherekaiskwhenTRANSA = 'N' or 'n', and ismotherwise. Before entry withTRANSA = 'N' or 'n', the leading m by k part of the arrayAmust contain the matrixA, otherwise the leading k by m part of the arrayAmust contain the matrixA.LDAβLDA is INTEGER. On entry,LDAspecifies the first dimension ofAas declared in the calling (sub) program. WhenTRANSA = 'N' or 'n'thenLDAmust be at leastmax( 1, m ), otherwiseLDAmust be at leastmax( 1, k ).BβB is COMPLEX*16 array, dimension ( LDB, kb ), wherekbisnwhenTRANSB = 'N' or 'n', and iskotherwise. Before entry withTRANSB = 'N' or 'n', the leading k by n part of the arrayBmust contain the matrixB, otherwise the leading n by k part of the arrayBmust contain the matrixB.LDBβLDB is INTEGER. On entry,LDBspecifies the first dimension ofBas declared in the calling (sub) program. WhenTRANSB = 'N' or 'n'thenLDBmust be at leastmax( 1, k ), otherwiseLDBmust be at leastmax( 1, n ).BETAβBETA is COMPLEX*16. On entry,BETAspecifies the scalar beta. WhenBETAis supplied as zero thenCneed not be set on input. Free pass on initializingC, we love to see it. πCβC is COMPLEX*16 array, dimension ( LDC, N ). Before entry, the leading m by n part of the arrayCmust contain the matrixC, except whenbetais zero, in which caseCneed not be set on entry. On exit, the arrayCis overwritten by the m by n matrix( alpha*op( A )*op( B ) + beta*C ).
β οΈ Again, for the people in the back: C gets overwritten on exit. Whatever was in there before is gone-gone. Save a copy if you need it. π
LDCβLDC is INTEGER. On entry,LDCspecifies the first dimension ofCas declared in the calling (sub) program.LDCmust be at leastmax( 1, m ).
πΈ Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
π Further Details
And the header comment, one more time, verbatim:
!>
!> 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.
!>
Level 3 Blas routine, written on 8-February-1989 by Jack Dongarra (Argonne National Laboratory), Iain Duff (AERE Harwell), Jeremy Du Croz (Numerical Algorithms Group Ltd.) and Sven Hammarling (Numerical Algorithms Group Ltd.). Double-complex iconique behavior only. β¨
...and that's literally where the source file itself starts spilling the tea π« β like, before any of the math even happens, the Fortran file opens with a whole little author shoutout baked right into the comments:
!>
!> 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.
!>
okay but the way this is a Level 3 Blas routine and they put it in the very first comment line like a little name tag at a party π iconic behavior honestly. And then the receipt: -- Written on 8-February-1989. bestie that is ancient in computer years and it's still out here doing matrix multiplication for you. Respect the elders π
The whole squad, in order, no cap:
- Jack Dongarra, Argonne National Laboratory
- Iain Duff, AERE Harwell
- Jeremy Du Croz, Numerical Algorithms Group Ltd.
- Sven Hammarling, Numerical Algorithms Group Ltd.
four legends, one subroutine, zero notes π we simply have to stan.
Also clocking the location details so you can find it yourself, because iykyk:
- Definition at line 186 of file
zgemm.f.
like, line 186, file zgemm.f β that's the exact spot in the source, go look, it's right there π¦
π Author π
Generated automatically by Doxygen for LAPACK from the source code.
Yeah so nobody hand-wrote this bad boy β Doxygen basically scraped it straight out of the LAPACK source code and served it up for us, which is lowkey the most efficient glow-up ever β¨ (no human author to thank for the manpage itself, the tool did all the heavy lifting π«Ά).
fr fr reminder before you go: everything above is the vibe and the facts β every flag, every argument, every default, every zgemm.f detail stayed exactly where it was. I just gave it a personality π
Okay that's the whole page, you made it to the end, slay π go forth and multiply your matrices, bestie.
π brought to you by LAPACK, Version 3.12.0, and this little gemm(3) page β mwah, see you in the next manpage π§ββοΈπΈ
π¦ where this page comes from
- arch rolling: lapack-doc 3.12.1-2 Β· custom
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms