Developer Reference for Intel® oneAPI Math Kernel Library for C
?gemm
Computes a matrix-matrix product with general matrices.
Syntax
void cblas_hgemm(const CBLAS_LAYOUT Layout, const CBLAS_TRANSPOSE transa,
const CBLAS_TRANSPOSE transb, const MKL_INT m, const MKL_INT n,
const MKL_INT k, const MKL_F16 alpha, const MKL_F16 *a, const MKL_INT lda,
const MKL_F16 *b, const MKL_INT ldb, const MKL_F16 beta, MKL_F16 *c,
const MKL_INT ldc);
void cblas_sgemm(const CBLAS_LAYOUT Layout, const CBLAS_TRANSPOSE transa,
const CBLAS_TRANSPOSE transb, const MKL_INT m, const MKL_INT n,
const MKL_INT k, const float alpha, const float *a, const MKL_INT lda,
const float *b, const MKL_INT ldb, const float beta, float *c,
const MKL_INT ldc);
void cblas_dgemm(const CBLAS_LAYOUT Layout, const CBLAS_TRANSPOSE transa,
const CBLAS_TRANSPOSE transb, const MKL_INT m, const MKL_INT n,
const MKL_INT k, const double alpha, const double *a, const MKL_INT lda,
const double *b, const MKL_INT ldb, const double beta, double *c,
const MKL_INT ldc);
void cblas_cgemm(const CBLAS_LAYOUT Layout, const CBLAS_TRANSPOSE transa,
const CBLAS_TRANSPOSE transb, const MKL_INT m, const MKL_INT n,
const MKL_INT k, const void *alpha, const void *a, const MKL_INT lda,
const void *b, const MKL_INT ldb, const void *beta, void *c,
const MKL_INT ldc);
void cblas_zgemm(const CBLAS_LAYOUT Layout, const CBLAS_TRANSPOSE transa,
const CBLAS_TRANSPOSE transb, const MKL_INT m, const MKL_INT n,
const MKL_INT k, const void *alpha, const void *a, const MKL_INT lda,
const void *b, const MKL_INT ldb, const void *beta, void *c,
const MKL_INT ldc);
Include Files
mkl.h
Description
The ?gemm routines compute a scalar-matrix-matrix product and add the result to a scalar-matrix product, with general matrices. The operation is defined as 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,
A , B and C are matrices:
\(op(A)\) is an m -by- k matrix,
\(op(B)\) is a k -by- n matrix and
\(C\) is an m -by- n matrix.
See also:
?gemm3m (Computes a scalar-matrix-matrix product using matrix multiplications and adds the result to a scalar-matrix product.) , BLAS-like extension routines, that use matrix multiplication for similar matrix-matrix operations
Input Parameters
Layout
Specifies whether two-dimensional array storage is row-major ( CblasRowMajor ) or column-major ( CblasColMajor ).
transa
Specifies the form of op(A) used in the matrix multiplication: if transa = 'N' or 'n' , then op(A) = A ; if transa = 'T' or 't' , then op(A) = A^{T} ; if transa = 'C' or 'c' , then op(A) = A^{H} .
transb
Specifies the form of op(B) used in the matrix multiplication: if transb = 'N' or 'n' , then op(B) = B ; if transb = 'T' or 't' , then op(B) = B^{T} ; if transb = 'C' or 'c' , then op(B) = B^{H} .
m
Specifies the number of rows of the matrix op(A) and of the matrix C . The value of m must be at least zero.
n
Specifies the number of columns of the matrix op(B) and the number of columns of the matrix C . The value of n must be at least zero.
k
Specifies the number of columns of the matrix op(A) and the number of rows of the matrix op(B) . The value of k must be at least zero.
alpha
Specifies the scalar alpha .
a
Array, size lda by 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 .
lda
Specifies the leading 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) . Specifies the leading dimension of a as declared in the calling (sub)program.
b
Array, size ldb by kb , where kb is n when transa = 'N' or 'n' , and is k otherwise. Before entry with transa = '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 .
ldb
Specifies the leading dimension of b as declared in the calling (sub)program. When transb = CblasNoTrans , then ldb must be at least max(1, k) , otherwise ldb must be at least max(1, n) .
beta
Specifies the scalar beta . When beta is equal to zero, then c need not be set on input.
c
Array, size ldc by n . Before entry, the leading m -by- n part of the array c must contain the matrix C , except when beta is equal to zero, in which case c need not be set on entry.
ldc
Output Parameters
c
Overwritten by the m -by- n matrix (alpha*op(A)*op(B) + beta*C) .
BLAS 95 Interface Notes
There exist FORTRAN 77 and FORTRAN 95 interfaces for this routine. See the Intel® oneMKL Fortran Developer Reference for details.