Computes alpha * op(A) %*% op(B) + beta * C, where
op(X) = t(X) when the corresponding trans flag is
TRUE. Routes internally to the most efficient resident
operation for the chosen transpose combination.
Arguments
- A
A matrix or
aMatrix.- B
A matrix or
aMatrix.- C
Optional matrix or
aMatrixto add after scaling;NULLomits the addition term.- alpha
Numeric scalar multiplier for
op(A) %*% op(B). Default1.0.- beta
Numeric scalar multiplier for
C. Default1.0.- transA
Logical; transpose
Abefore multiplying. DefaultFALSE.- transB
Logical; transpose
Bbefore multiplying. DefaultFALSE.
Examples
A <- adgeMatrix(matrix(1:6, 2, 3))
B <- adgeMatrix(matrix(1:6, 2, 3))
gemm(A, B, transA = TRUE) # t(A) %*% B
#> An amatrix dense matrix [cpu|policy=auto|precision=strict]
#> 3 x 3 Matrix of class "adgeMatrix"
#> [,1] [,2] [,3]
#> [1,] 5 11 17
#> [2,] 11 25 39
#> [3,] 17 39 61
gemm(A, B, transB = TRUE) # A %*% t(B)
#> An amatrix dense matrix [cpu|policy=auto|precision=strict]
#> 2 x 2 Matrix of class "adgeMatrix"
#> [,1] [,2]
#> [1,] 35 44
#> [2,] 44 56