BLAS/SRC/cgemm.f(3)

πŸ’… BLAS/SRC/cgemm.f(3) β€” from the Library Functions Manual ✨

okay bestie, sit down, because today we're talking about cgemm and honestly? she's iconic. this is the complex single-precision matrix-matrix multiply, the level-3 BLAS queen herself. no cap. πŸŽ€


🌸 NAME 🌸

BLAS/SRC/cgemm.f β€” that's the file, that's the vibe, that's the whole legend.


✨ SYNOPSIS ✨

🫢 Functions/Subroutines

  • subroutine cgemm (transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc) β€” literally CGEMM, the main character πŸ’–

πŸ‘‘ Function/Subroutine 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:

!>
!> CGEMM  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.
!>

so basically: you hand her A and B, she does the whole alpha*op(A)*op(B) + beta*C thing, and C comes back looking different. it's giving glow-up. it's giving linear algebra. we love to see it. πŸ’…


πŸŽ€ Parameters πŸŽ€

TRANSA

!>          TRANSA is CHARACTER*1
!>           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**T.
!>
!>              TRANSA = 'C' or 'c',  op( A ) = A**H.
!>

this is you telling her what to do with A, bestie. 'N' / 'n' = leave her alone, she's perfect (op( A ) = A). 'T' / 't' = transpose her (op( A ) = A**T). 'C' / 'c' = conjugate transpose, aka the full transformation (op( A ) = A**H). choose wisely. πŸ¦‹

TRANSB

!>          TRANSB is CHARACTER*1
!>           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**T.
!>
!>              TRANSB = 'C' or 'c',  op( B ) = B**H.
!>

same energy as TRANSA but for B ✨. 'N' / 'n' keeps her as op( B ) = B, 'T' / 't' transposes her to op( B ) = B**T, and 'C' / 'c' conjugate-transposes her to op( B ) = B**H.

M

!>          M is INTEGER
!>           On entry,  M  specifies  the number  of rows  of the  matrix
!>           op( A )  and of the  matrix  C.  M  must  be at least  zero.
!>

rows of op( A ) and rows of C. and M must be at least zero β€” like, M >= 0, no negativity allowed in this house 🚫😀.

N

!>          N is 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 zero.
!>

columns of op( B ), columns of C. also must be at least zero, same rules, the girls are consistent πŸ’–.

K

!>          K is 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  zero.
!>

columns of op( A ), rows of op( B ) β€” she's the bridge between the two, the moment where they actually match up 😭. at least zero, always.

ALPHA

!>          ALPHA is COMPLEX
!>           On entry, ALPHA specifies the scalar alpha.
!>

that's the scalar alpha. complex. she scales things. that's her job 🌸.

A

!>          A is COMPLEX array, 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.
!>

okay here's the part that trips people up ngl. A is a COMPLEX array with dimension ( LDA, ka ), where ka is k if TRANSA = 'N' or 'n', and is m otherwise. and yeah β€” on entry, if TRANSA = 'N' or 'n', the leading m by k part of A has to hold the matrix A; otherwise the leading k by m part holds it. the shape literally flips based on TRANSA, iykyk πŸ”₯.

LDA

!>          LDA is 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 ).
!>

the first dimension of A as you declared it in your calling (sub) program. if TRANSA = 'N' or 'n', then LDA must be at least max( 1, m ). otherwise it must be at least max( 1, k ). don't fumble this, it's a whole vibe check 🫢.

B

!>          B is COMPLEX array, 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.
!>

same deal for B πŸ’œ. COMPLEX array, dimension ( LDB, kb ), kb is n when TRANSB = 'N' or 'n', otherwise k. on entry with TRANSB = 'N' or 'n', the leading k by n part holds B; otherwise the leading n by k part holds it.

LDB

!>          LDB is 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 ).
!>

first dimension of B, as declared in your calling (sub) program. TRANSB = 'N' or 'n' β†’ LDB at least max( 1, k ); otherwise at least max( 1, n ). matching set with LDA, adorable 🌟.

BETA

!>          BETA is COMPLEX
!>           On entry,  BETA  specifies the scalar  beta.  When  BETA  is
!>           supplied as zero then C need not be set on input.
!>

the scalar beta πŸ’…. and here's the cute part: when BETA is supplied as zero, then C need not be set on input. free real estate. you don't have to initialize her. slay.

C

!>          C is COMPLEX array, dimension ( LDC, N )
!>           Before entry, the leading  m by n  part of the array  C must
!>           contain the matrix  C,  except when  beta  is zero, 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 ).
!>

COMPLEX array, dimension ( LDC, N ) πŸ‘‘. before entry, the leading m by n part must contain the matrix C β€” except when beta is zero, in which case C need not be set on entry (again: free real estate ✨). and on exit? the array C is overwritten by the m by n matrix ( alpha*op( A )*op( B ) + beta*C ). she comes in, she rewrites everything, she leaves. main character behaviour, truly.

⚠️ careful bestie β€” that's an overwrite, not a suggestion. your old C is gone. periodt. πŸ’€

LDC

!>          LDC is 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 ).
!>

first dimension of C, as declared in your calling (sub) program, and LDC must be at least max( 1, m ). final answer πŸ’–.


🧚 Author 🧚

  • Univ. of Tennessee
  • Univ. of California Berkeley
  • Univ. of Colorado Denver
  • NAG Ltd.

look at this group project. the avengers of numerical computing, fr fr 😭🫢


⭐ 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.
!>

Level 3 Blas routine. that's the classification, she's a level 3 girlie πŸ”₯

and the receipts: 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.). 1989!! these icons were doing matrix math before most of us existed and the code still eats today πŸ‘‘πŸ’œ

Definition at line 186 of file cgemm.f.


🌸 Author 🌸

Generated automatically by Doxygen for LAPACK from the source code. (yes, a robot wrote the docs. she's doing her best. respect her πŸ™ˆβœ¨)


πŸ’Œ and that's the whole page bestie! this lil beauty is LAPACK, Version 3.12.0, and the whole thing lives over at BLAS/SRC/cgemm.f(3). go forth, multiply your matrices, and remember: beta zero means C doesn't have to be set, but LDA/LDB/LDC are never optional. love u, bye!! πŸŽ€πŸ’–πŸŒˆπŸ¦‹πŸ’…
πŸ“¦ where this page comes from