# NAG FL Interfacef11mkf (direct_​real_​gen_​matmul)

## 1Purpose

f11mkf computes a matrix-matrix or transposed matrix-matrix product involving a real, square, sparse nonsymmetric matrix stored in compressed column (Harwell–Boeing) format.

## 2Specification

Fortran Interface
 Subroutine f11mkf ( n, m, a, b, ldb, beta, c, ldc,
 Integer, Intent (In) :: n, m, icolzp(*), irowix(*), ldb, ldc Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: alpha, a(*), b(ldb,*), beta Real (Kind=nag_wp), Intent (Inout) :: c(ldc,*) Character (1), Intent (In) :: trans
#include <nag.h>
 void f11mkf_ (const char *trans, const Integer *n, const Integer *m, const double *alpha, const Integer icolzp[], const Integer irowix[], const double a[], const double b[], const Integer *ldb, const double *beta, double c[], const Integer *ldc, Integer *ifail, const Charlen length_trans)
The routine may be called by the names f11mkf or nagf_sparse_direct_real_gen_matmul.

## 3Description

f11mkf computes either the matrix-matrix product $C←\alpha AB+\beta C$, or the transposed matrix-matrix product $C←\alpha {A}^{\mathrm{T}}B+\beta C$, according to the value of the argument trans, where $A$ is a real $n$ by $n$ sparse nonsymmetric matrix, of arbitrary sparsity pattern with $\mathit{nnz}$ nonzero elements, $B$ and $C$ are $n$ by $m$ real dense matrices. The matrix $A$ is stored in compressed column (Harwell–Boeing) storage format. The array a stores all nonzero elements of $A$, while arrays icolzp and irowix store the compressed column indices and row indices of $A$ respectively.

None.

## 5Arguments

1: $\mathbf{trans}$Character(1) Input
On entry: specifies whether or not the matrix $A$ is transposed.
${\mathbf{trans}}=\text{'N'}$
$\alpha AB+\beta C$ is computed.
${\mathbf{trans}}=\text{'T'}$
$\alpha {A}^{\mathrm{T}}B+\beta C$ is computed.
Constraint: ${\mathbf{trans}}=\text{'N'}$ or $\text{'T'}$.
2: $\mathbf{n}$Integer Input
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.
3: $\mathbf{m}$Integer Input
On entry: $m$, the number of columns of matrices $B$ and $C$.
Constraint: ${\mathbf{m}}\ge 0$.
4: $\mathbf{alpha}$Real (Kind=nag_wp) Input
On entry: $\alpha$, the scalar factor in the matrix multiplication.
5: $\mathbf{icolzp}\left(*\right)$Integer array Input
Note: the dimension of the array icolzp must be at least ${\mathbf{n}}+1$.
On entry: ${\mathbf{icolzp}}\left(i\right)$ contains the index in $A$ of the start of a new column. See Section 2.1.3 in the F11 Chapter Introduction.
6: $\mathbf{irowix}\left(*\right)$Integer array Input
Note: the dimension of the array irowix must be at least ${\mathbf{icolzp}}\left({\mathbf{n}}+1\right)-1$, the number of nonzeros of the sparse matrix $A$.
On entry: the row index array of sparse matrix $A$.
7: $\mathbf{a}\left(*\right)$Real (Kind=nag_wp) array Input
Note: the dimension of the array a must be at least ${\mathbf{icolzp}}\left({\mathbf{n}}+1\right)-1$, the number of nonzeros of the sparse matrix $A$.
On entry: the array of nonzero values in the sparse matrix $A$.
8: $\mathbf{b}\left({\mathbf{ldb}},*\right)$Real (Kind=nag_wp) array Input
Note: the second dimension of the array b must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$.
On entry: the $n$ by $m$ matrix $B$.
9: $\mathbf{ldb}$Integer Input
On entry: the first dimension of the array b as declared in the (sub)program from which f11mkf is called.
Constraint: ${\mathbf{ldb}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
10: $\mathbf{beta}$Real (Kind=nag_wp) Input
On entry: the scalar factor $\beta$.
11: $\mathbf{c}\left({\mathbf{ldc}},*\right)$Real (Kind=nag_wp) array Input/Output
Note: the second dimension of the array c must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$.
On entry: the $n$ by $m$ matrix $C$.
On exit: $C$ is overwritten by $\alpha AB+\beta C$ or $\alpha {A}^{\mathrm{T}}B+\beta C$ depending on the value of trans.
12: $\mathbf{ldc}$Integer Input
On entry: the first dimension of the array c as declared in the (sub)program from which f11mkf is called.
Constraint: ${\mathbf{ldc}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
13: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, . If you are unfamiliar with this argument you should refer to Section 4 in the Introduction to the NAG Library FL Interface for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this argument, the recommended value is $0$. When the value 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{ldb}}=〈\mathit{\text{value}}〉$ and ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{ldb}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry, ${\mathbf{ldc}}=〈\mathit{\text{value}}〉$ and ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{ldc}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry, ${\mathbf{m}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{m}}\ge 0$.
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 0$.
On entry, ${\mathbf{trans}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{trans}}=\text{'N'}$ or $\text{'T'}$.
${\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.

Not applicable.

## 8Parallelism and Performance

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

None.

## 10Example

This example reads in a sparse matrix $A$ and a dense matrix $B$. It then calls f11mkf to compute the matrix-matrix product $C=AB$ and the transposed matrix-matrix product $C={A}^{\mathrm{T}}B$, where
 $A= 2.00 1.00 0 0 0 0 0 1.00 -1.00 0 4.00 0 1.00 0 1.00 0 0 0 1.00 2.00 0 -2.00 0 0 3.00 and B= 0.70 1.40 0.16 0.32 0.52 1.04 0.77 1.54 0.28 0.56 .$

### 10.1Program Text

Program Text (f11mkfe.f90)

### 10.2Program Data

Program Data (f11mkfe.d)

### 10.3Program Results

Program Results (f11mkfe.r)