# NAG Library Routine Document

## 1Purpose

f06yaf (dgemm) performs one of the matrix-matrix operations
 $C←αAB+βC, C←αATB+βC, C←αABT+βC or C←αATBT+βC,$
where $A$, $B$ and $C$ are real matrices, and $\alpha$ and $\beta$ are real scalars; $C$ is always $m$ by $n$.

## 2Specification

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

None.

None.

## 5Arguments

1:     $\mathbf{transa}$ – Character(1)Input
On entry: specifies whether the operation involves $A$ or ${A}^{\mathrm{T}}$.
${\mathbf{transa}}=\text{'N'}$
The operation involves $A$.
${\mathbf{transa}}=\text{'T'}$ or $\text{'C'}$
The operation involves ${A}^{\mathrm{T}}$.
Constraint: ${\mathbf{transa}}=\text{'N'}$, $\text{'T'}$ or $\text{'C'}$.
2:     $\mathbf{transb}$ – Character(1)Input
On entry: specifies whether the operation involves $B$ or ${B}^{\mathrm{T}}$.
${\mathbf{transb}}=\text{'N'}$
The operation involves $B$.
${\mathbf{transb}}=\text{'T'}$ or $\text{'C'}$
The operation involves ${B}^{\mathrm{T}}$.
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}$ – Real (Kind=nag_wp)Input
On entry: the scalar $\alpha$.
7:     $\mathbf{a}\left({\mathbf{lda}},*\right)$ – Real (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 f06yaf (dgemm) 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)$ – Real (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 f06yaf (dgemm) 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}$ – Real (Kind=nag_wp)Input
On entry: the scalar $\beta$.
12:   $\mathbf{c}\left({\mathbf{ldc}},*\right)$ – Real (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 f06yaf (dgemm) is called.
Constraint: ${\mathbf{ldc}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$.

None.

Not applicable.

## 8Parallelism and Performance

f06yaf (dgemm) 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.