Developer Reference for Intel® oneAPI Math Kernel Library for Fortran

ID 766686
Date 7/13/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

?gemm3m

Computes a scalar-matrix-matrix product using matrix multiplications and adds the result to a scalar-matrix product.

Syntax

call cgemm3m(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)

call zgemm3m(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)

call gemm3m(a, b, c [,transa][,transb] [,alpha][,beta])

Include Files

  • mkl.fi, blas.f90

Description

The ?gemm3m routines perform a matrix-matrix operation with general complex matrices. These routines are similar to the ?gemm routines, but they use fewer matrix multiplication operations (see Application Notes below).

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', or op(x) = conjg(x'),

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,

C is an m-by-n matrix.

Input Parameters

transa

CHARACTER*1. 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';

if transa = 'C' or 'c', then op(A) = conjg(A').

transb

CHARACTER*1. 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';

if transb = 'C' or 'c', then op(B) = conjg(B').

m

INTEGER. 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

INTEGER. 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

INTEGER. 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

COMPLEX for cgemm3m

DOUBLE COMPLEX for zgemm3m

Specifies the scalar alpha.

a

COMPLEX for cgemm3m

DOUBLE COMPLEX for zgemm3m

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

INTEGER. 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).

b

COMPLEX for cgemm3m

DOUBLE COMPLEX for zgemm3m

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

INTEGER. Specifies the leading dimension of b as declared in the calling (sub)program.

When transa = 'N' or 'n', then ldb must be at least max(1, k), otherwise ldb must be at least max(1, n).

beta

COMPLEX for cgemm3m

DOUBLE COMPLEX for zgemm3m

Specifies the scalar beta.

When beta is equal to zero, then c need not be set on input.

c

COMPLEX for cgemm3m

DOUBLE COMPLEX for zgemm3m

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

INTEGER. Specifies the leading dimension of c as declared in the calling (sub)program.

The value of ldc must be at least max(1, m).

Output Parameters

c

Overwritten by the m-by-n matrix (alpha*op(A)*op(B) + beta*C).

BLAS 95 Interface Notes

Routines in Fortran 95 interface have fewer arguments in the calling sequence than their FORTRAN 77 counterparts. For general conventions applied to skip redundant or reconstructible arguments, see BLAS 95 Interface Conventions.

Specific details for the routine gemm3m interface are the following:

a

Holds the matrix A of size (ma,ka) where

ka = k if transa='N',

ka = m otherwise,

ma = m if transa='N',

ma = k otherwise.

b

Holds the matrix B of size (mb,kb) where

kb = n if transb = 'N',

kb = k otherwise,

mb = k if transb = 'N',

mb = n otherwise.

c

Holds the matrix C of size (m,n).

transa

Must be 'N', 'C', or 'T'.

The default value is 'N'.

transb

Must be 'N', 'C', or 'T'.

The default value is 'N'.

alpha

The default value is 1.

beta

The default value is 1.

Application Notes

These routines perform a complex matrix multiplication by forming the real and imaginary parts of the input matrices. This uses three real matrix multiplications and five real matrix additions instead of the conventional four real matrix multiplications and two real matrix additions. The use of three real matrix multiplications reduces the time spent in matrix operations by 25%, resulting in significant savings in compute time for large matrices.

If the errors in the floating point calculations satisfy the following conditions:

fl(x op y)=(x op y)(1+δ),|δ|≤u, op=×,/, fl(x±y)=x(1+α)±y(1+β), |α|,|β|≤u

then for an n-by-n matrix Ĉ=fl(C1+iC2)= fl((A1+iA2)(B1+iB2))=Ĉ1+iĈ2, the following bounds are satisfied:

Ĉ1-C1║≤ 2(n+1)uAB+O(u2),

Ĉ2-C2║≤ 4(n+4)uAB+O(u2),

where A=max(║A1,║A2), and B=max(║B1,║B2).

Thus the corresponding matrix multiplications are stable.