# NAG Library Routine Document

## 1Purpose

f06zaf (zgemm) performs one of the matrix-matrix operations
 $C←αAB+βC, C←αATB+βC, C←αAHB+βC, C←αABT+βC, C←αATBT+βC, C←αAHBT+βC, C←αABH+βC, C←αATBH+βC or C←αAHBH+βC,$
where $A$, $B$ and $C$ are complex matrices, and $\alpha$ and $\beta$ are complex scalars; $C$ is always $m$ by $n$.

## 2Specification

Fortran Interface
 Subroutine f06zaf ( m, n, k, a, lda, b, ldb, beta, c, ldc)
 Integer, Intent (In) :: m, n, k, lda, ldb, ldc Complex (Kind=nag_wp), Intent (In) :: alpha, a(lda,*), b(ldb,*), beta Complex (Kind=nag_wp), Intent (Inout) :: c(ldc,*) Character (1), Intent (In) :: transa, transb
#include nagmk26.h
 void f06zaf_ ( const char *transa, const char *transb, const Integer *m, const Integer *n, const Integer *k, const Complex *alpha, const Complex a[], const Integer *lda, const Complex b[], const Integer *ldb, const Complex *beta, Complex c[], const Integer *ldc, const Charlen length_transa, const Charlen length_transb)
The routine may be called by its BLAS name zgemm.

None.

None.

## 5Arguments

1:     $\mathbf{transa}$ – Character(1)Input
On entry: specifies whether the operation involves $A$, ${A}^{\mathrm{T}}$ or ${A}^{\mathrm{H}}$.
${\mathbf{transa}}=\text{'N'}$
The operation involves $A$.
${\mathbf{transa}}=\text{'T'}$
The operation involves ${A}^{\mathrm{T}}$.
${\mathbf{transa}}=\text{'C'}$
The operation involves ${A}^{\mathrm{H}}$.
Constraint: ${\mathbf{transa}}=\text{'N'}$, $\text{'T'}$ or $\text{'C'}$.
2:     $\mathbf{transb}$ – Character(1)Input
On entry: specifies whether the operation involves $B$, ${B}^{\mathrm{T}}$ or ${B}^{\mathrm{H}}$.
${\mathbf{transb}}=\text{'N'}$
The operation involves $B$.
${\mathbf{transb}}=\text{'T'}$
The operation involves ${B}^{\mathrm{T}}$.
${\mathbf{transb}}=\text{'C'}$
The operation involves ${B}^{\mathrm{H}}$.
Constraint: ${\mathbf{transb}}=\text{'N'}$, $\text{'T'}$ or $\text{'C'}$.
3:     $\mathbf{m}$ – IntegerInput
On entry: $m$, the number of rows of the matrix $C$; the number of rows of $A$ if ${\mathbf{transa}}=\text{'N'}$, or the number of columns of $A$ if ${\mathbf{transa}}=\text{'T'}$ or $\text{'C'}$.
Constraint: ${\mathbf{m}}\ge 0$.
4:     $\mathbf{n}$ – IntegerInput
On entry: $n$, the number of columns of the matrix $C$; the number of columns of $B$ if ${\mathbf{transb}}=\text{'N'}$, or the number of rows of $B$ if ${\mathbf{transb}}=\text{'T'}$ or $\text{'C'}$.
Constraint: ${\mathbf{n}}\ge 0$.
5:     $\mathbf{k}$ – IntegerInput
On entry: $k$, the number of columns of $A$ if ${\mathbf{transa}}=\text{'N'}$, or the number of rows of $A$ if ${\mathbf{transa}}=\text{'T'}$ or $\text{'C'}$; the number of rows of $B$ if ${\mathbf{transb}}=\text{'N'}$, or the number of columns of $B$ if ${\mathbf{transb}}=\text{'T'}$ or $\text{'C'}$.
Constraint: ${\mathbf{k}}\ge 0$.
6:     $\mathbf{alpha}$ – Complex (Kind=nag_wp)Input
On entry: the scalar $\alpha$.
7:     $\mathbf{a}\left({\mathbf{lda}},*\right)$ – Complex (Kind=nag_wp) arrayInput
Note: the second dimension of the array a must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{k}}\right)$ if ${\mathbf{transa}}=\text{'N'}$ and at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$ if ${\mathbf{transa}}=\text{'T'}$ or $\text{'C'}$.
On entry: the matrix $A$; $A$ is $m$ by $k$ if ${\mathbf{transa}}=\text{'N'}$, or $k$ by $m$ if ${\mathbf{transa}}=\text{'T'}$ or $\text{'C'}$.
8:     $\mathbf{lda}$ – IntegerInput
On entry: the first dimension of the array a as declared in the (sub)program from which f06zaf (zgemm) is called.
Constraints:
• if ${\mathbf{transa}}=\text{'N'}$, ${\mathbf{lda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$;
• if ${\mathbf{transa}}=\text{'T'}$ or $\text{'C'}$, ${\mathbf{lda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{k}}\right)$.
9:     $\mathbf{b}\left({\mathbf{ldb}},*\right)$ – Complex (Kind=nag_wp) arrayInput
Note: the second dimension of the array b must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$ if ${\mathbf{transb}}=\text{'N'}$ and at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{k}}\right)$ if ${\mathbf{transb}}=\text{'T'}$ or $\text{'C'}$.
On entry: the matrix $B$; $B$ is $k$ by $n$ if ${\mathbf{transb}}=\text{'N'}$, or $n$ by $k$ if ${\mathbf{transb}}=\text{'T'}$ or $\text{'C'}$.
10:   $\mathbf{ldb}$ – IntegerInput
On entry: the first dimension of the array b as declared in the (sub)program from which f06zaf (zgemm) is called.
Constraints:
• if ${\mathbf{transb}}=\text{'N'}$, ${\mathbf{ldb}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{k}}\right)$;
• if ${\mathbf{transb}}=\text{'T'}$ or $\text{'C'}$, ${\mathbf{ldb}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
11:   $\mathbf{beta}$ – Complex (Kind=nag_wp)Input
On entry: the scalar $\beta$.
12:   $\mathbf{c}\left({\mathbf{ldc}},*\right)$ – Complex (Kind=nag_wp) arrayInput/Output
Note: the second dimension of the array c must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry: the $m$ by $n$ matrix $C$.
If ${\mathbf{beta}}=0$, c need not be set.
On exit: the updated matrix $C$.
13:   $\mathbf{ldc}$ – IntegerInput
On entry: the first dimension of the array c as declared in the (sub)program from which f06zaf (zgemm) is called.
Constraint: ${\mathbf{ldc}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$.

None.

Not applicable.

## 8Parallelism and Performance

f06zaf (zgemm) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.