({{, GEMM[tsa,tsb,α,a,b,β,c] 
computes the matrix-matrix multiplication α (Subscript[op, tsa])[a].(Subscript[op, tsb])[b]+β c and resets c to the result.}})

OpenersNotesSection(Spacer1)Details

To use GEMM, you first need to load the BLAS Package using (RefLink[Needs, paclet:ref/Needs])["LinearAlgebra`BLAS`"].

The following arguments must be given:

The transposition strings describing the operators (Subscript[op, tsa]) and (Subscript[op, tsb]) and may be specified as:

Dimensions of the matrix arguments must be such that the dot product and addition are well defined.

OpenersPrimaryExamplesSection(Spacer1)Examples  (10)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Load the BLAS package:

Needs["LinearAlgebra`BLAS`"]

Compute (RefLink[Transpose, paclet:ref/Transpose])[a].b+2 c and save it in c:

c={{0,2},{2,-4}};
a={{1,3},{2,4}};
b={{-1,2},{2,-1}};
GEMM["T","N",1,a,b,2,c];
c

OpenersExampleSection1(Spacer1)Scope  (4)

Real matrices:

c={{2.3,1.2},{3.7,1.5}};
a={{-2.1,0},{1.4,2.4}};
b={{0,1.2},{-1.3,4.6}};
GEMM["N","N",2,a,b,1,c];
c

Complex matrices:

c={{2.3+3.I,1.2 I},{-3.+2.I,4.1}};
a={{2.1,1.4 I},{3.5 I,0.4+I}};
b={{0,1.2},{-1.3-2.I,-1.0}};
GEMM["N","C",2I,a,b,1,c];
c

Arbitrary-precision matrices:

c={{0,2`20},{2`20,-4}};
a={{1,3},{2,4}};
b={{-1,2},{2,-1}};
GEMM["T","N",1,a,b,2,c];
c

Symbolic matrices:

Clear[c1,c2];
c={{c1},{c2}};
a={{a11,a12},{a21,a22}};
b={{b1},{b2}};
GEMM["N","N",α,a,b,β,c];
c

OpenersExampleSection3(Spacer1)Properties & Relations  (3)

GEMM["N","N",α,a,b,β,c] is equivalent to c=α a.b+β c:

c=c1=RandomReal[1,{4,5}];
a=RandomReal[1,{4,4}];
b=RandomReal[1,{4,5}];
GEMM["N","N",3,a,b,-2,c];
c==3 a.b-2 c1

GEMM["T","N",α,a,b,β,b] is equivalent to c=α (RefLink[Transpose, paclet:ref/Transpose])[a].b+β c:

c=c1=RandomReal[1,{4,5}];
a=RandomReal[1,{4,4}];
b=RandomReal[1,{4,5}];
GEMM["T","N",3,a,b,-2,c];
c==3 Transpose[a].b-2 c1

GEMM[(StringTypeLink["C", paclet:ref/format/C]),"T",α,a,b,β,b] is equivalent to c=α (RefLink[ConjugateTranspose, paclet:ref/ConjugateTranspose])[a].(RefLink[Transpose, paclet:ref/Transpose])[b]+β c:

c=c1=RandomComplex[1+I,{4,5}];
a=RandomComplex[1+I,{4,4}];
b=RandomComplex[1+I,{5,4}];
GEMM["C","T",3+2I,a,b,-2+I,c];
c==(3+2I) ConjugateTranspose[a].Transpose[b]+(-2+I) c1

OpenersExampleSection4(Spacer1)Possible Issues  (2)

The last argument must be a symbol:

a={{1,3},{2,4}};
b={{1,2},{1,2}};
GEMM["N","N",1,a,b,2,{{2,3},{0,1}}]

The last argument must be initialized to a matrix:

Clear[c];
a={{1,3},{2,4}};
b={{1,2},{1,2}};
GEMM["N","N",1,a,b,2,c]

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Basic Linear Algebra Subroutines, paclet:LowLevelLinearAlgebra/guide/BLASGuide])}})}})