F11 Chapter Contents
F11 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF11MKF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

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

## 2  Specification

 SUBROUTINE F11MKF ( TRANS, N, M, ALPHA, ICOLZP, IROWIX, A, B, LDB, BETA, C, LDC, IFAIL)
 INTEGER N, M, ICOLZP(*), IROWIX(*), LDB, LDC, IFAIL REAL (KIND=nag_wp) ALPHA, A(*), B(LDB,*), BETA, C(LDC,*) CHARACTER(1) TRANS

## 3  Description

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

## 5  Parameters

1:     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:     N – INTEGERInput
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{N}}\ge 0$.
3:     M – INTEGERInput
On entry: $m$, the number of columns of matrices $B$ and $C$.
Constraint: ${\mathbf{M}}\ge 0$.
4:     ALPHA – REAL (KIND=nag_wp)Input
On entry: $\alpha$, the scalar factor in the matrix multiplication.
5:     ICOLZP($*$) – INTEGER arrayInput
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:     IROWIX($*$) – INTEGER arrayInput
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:     A($*$) – REAL (KIND=nag_wp) arrayInput
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:     B(LDB,$*$) – 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{M}}\right)$.
On entry: the $n$ by $m$ matrix $B$.
9:     LDB – INTEGERInput
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:   BETA – REAL (KIND=nag_wp)Input
On entry: the scalar factor $\beta$.
11:   C(LDC,$*$) – 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{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:   LDC – INTEGERInput
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:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ 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).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{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{TRANS}}\ne \text{'N'}$ or $\text{'T'}$, or ${\mathbf{N}}<0$, or ${\mathbf{M}}<0$, or ${\mathbf{LDB}}<\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$, or ${\mathbf{LDC}}<\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.

Not applicable.

None.

## 9  Example

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

### 9.1  Program Text

Program Text (f11mkfe.f90)

### 9.2  Program Data

Program Data (f11mkfe.d)

### 9.3  Program Results

Program Results (f11mkfe.r)