# NAG FL Interfacef01ckf (real_​gen_​matmul)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

f01ckf returns with the result of the multiplication of two matrices $B$ and $C$ in the matrix $A$, with the option to overwrite $B$ or $C$.

## 2Specification

Fortran Interface
 Subroutine f01ckf ( a, b, c, n, p, m, z, iz, opt,
 Integer, Intent (In) :: n, p, m, iz, opt Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (Inout) :: b(n,m), c(m,p) Real (Kind=nag_wp), Intent (Out) :: a(n,p), z(iz)
#include <nag.h>
 void f01ckf_ (double a[], double b[], double c[], const Integer *n, const Integer *p, const Integer *m, double z[], const Integer *iz, const Integer *opt, Integer *ifail)
The routine may be called by the names f01ckf or nagf_matop_real_gen_matmul.

## 3Description

The $n×m$ matrix $B$ is post-multiplied by the $m×p$ matrix $C$. If ${\mathbf{opt}}=1$ the result is formed in the $n×p$ matrix $A$. If ${\mathbf{opt}}=2$, $m$ must equal $p$, and the result is written back to $B$. If ${\mathbf{opt}}=3$, $n$ must equal $m$, and the result is written back to $C$.

None.

## 5Arguments

1: $\mathbf{a}\left({\mathbf{n}},{\mathbf{p}}\right)$Real (Kind=nag_wp) array Output
On exit: if ${\mathbf{opt}}=1$, a contains the result of the matrix multiplication.
2: $\mathbf{b}\left({\mathbf{n}},{\mathbf{m}}\right)$Real (Kind=nag_wp) array Input/Output
On entry: the $n×m$ matrix $B$.
On exit: if ${\mathbf{opt}}=2$, b contains the result of the multiplication.
3: $\mathbf{c}\left({\mathbf{m}},{\mathbf{p}}\right)$Real (Kind=nag_wp) array Input/Output
On entry: the $m×p$ matrix $C$.
On exit: if ${\mathbf{opt}}=3$, c contains the result of the multiplication.
4: $\mathbf{n}$Integer Input
On entry: $n$, the number of rows of the array $A$ and of the array $B$.
Constraints:
• if ${\mathbf{opt}}=3$, ${\mathbf{n}}={\mathbf{m}}$;
• otherwise ${\mathbf{n}}\ge 1$.
5: $\mathbf{p}$Integer Input
On entry: $p$, the number of columns of the array $A$ and of the array $C$.
Constraints:
• if ${\mathbf{opt}}=2$, ${\mathbf{p}}={\mathbf{m}}$;
• otherwise ${\mathbf{p}}\ge 1$.
6: $\mathbf{m}$Integer Input
On entry: $m$, the number of columns of the array $B$ and rows of the array $C$.
Constraints:
• if ${\mathbf{opt}}=2$, ${\mathbf{m}}={\mathbf{p}}$;
• if ${\mathbf{opt}}=3$, ${\mathbf{m}}={\mathbf{n}}$;
• if ${\mathbf{opt}}\ne 1$, ${\mathbf{m}}\le {\mathbf{iz}}$;
• otherwise ${\mathbf{m}}\ge 1$.
7: $\mathbf{z}\left({\mathbf{iz}}\right)$Real (Kind=nag_wp) array Workspace
8: $\mathbf{iz}$Integer Input
On entry: the dimension of the array z as declared in the (sub)program from which f01ckf is called.
Constraints:
• if ${\mathbf{opt}}=1$, ${\mathbf{iz}}\ge 1$;
• if ${\mathbf{opt}}\ne 1$, ${\mathbf{iz}}\ge {\mathbf{m}}$.
9: $\mathbf{opt}$Integer Input
On entry: the value of opt determines which array is to contain the final result.
${\mathbf{opt}}=1$
a must be distinct from b and c and, on exit, contains the result. b and c need not be distinct in this case.
${\mathbf{opt}}=2$
b must be distinct from c and on exit, contains the result. a is not used in this case and need not be distinct from b or c.
${\mathbf{opt}}=3$
c must be distinct from b and on exit, contains the result. a is not used in this case and need not be distinct from b or c.
Constraint: $1\le {\mathbf{opt}}\le 3$.
10: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ or $\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit: ${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6Error Indicators and Warnings

If on entry ${\mathbf{ifail}}=0$ or $-1$, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
${\mathbf{ifail}}=1$
On entry, ${\mathbf{m}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{m}}\ge 1$.
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}\ge 1$.
On entry, ${\mathbf{p}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{p}}\ge 1$.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{m}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{p}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{opt}}=2$, ${\mathbf{m}}={\mathbf{p}}$.
${\mathbf{ifail}}=3$
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{m}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{opt}}=3$, ${\mathbf{n}}={\mathbf{m}}$.
${\mathbf{ifail}}=4$
On entry, ${\mathbf{opt}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{iz}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{m}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{opt}}\ne 1$, ${\mathbf{iz}}\ge {\mathbf{m}}$.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

## 7Accuracy

Each element of the result is effectively computed as an inner product using basic precision.

## 8Parallelism and Performance

f01ckf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
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.

The time taken by f01ckf is approximately proportional to $mnp$.

## 10Example

This example multiplies the $2×3$ matrix $B$ and the $3×2$ matrix $C$ together and places the result in the $2×2$ matrix $A$.

### 10.1Program Text

Program Text (f01ckfe.f90)

### 10.2Program Data

Program Data (f01ckfe.d)

### 10.3Program Results

Program Results (f01ckfe.r)