f11 Chapter Contents
f11 Chapter Introduction
NAG Library Manual

# NAG Library Function Documentnag_sparse_sym_rcm (f11yec)

## 1  Purpose

nag_sparse_sym_rcm (f11yec) reduces the bandwidth of a sparse symmetric matrix stored in compressed column storage format using the Reverse Cuthill–McKee algorithm.

## 2  Specification

 #include #include
 void nag_sparse_sym_rcm (Integer n, Integer nnz, const Integer icolzp[], const Integer irowix[], const Nag_Boolean lopts[], const Integer mask[], Integer perm[], Integer info[], NagError *fail)

## 3  Description

nag_sparse_sym_rcm (f11yec) takes the compressed column storage (CCS) representation (see Section 2.1.3 in the f11 Chapter Introduction) of an $n$ by $n$ symmetric matrix $A$ and applies the Reverse Cuthill–McKee (RCM) algorithm which aims to minimize the bandwidth of the matrix $A$ by reordering the rows and columns symmetrically. This also results in a lower profile of the matrix (see Section 9).
nag_sparse_sym_rcm (f11yec) can be useful for solving systems of equations $Ax=b$, as the permuted system $PA{P}^{\mathrm{T}}\left(Px\right)=Pb$ (where $P$ is the permutation matrix described by the vector perm returned by nag_sparse_sym_rcm (f11yec)) may require less storage space and/or less computational steps when solving (see Wai-Hung and Sherman (1976)).
nag_sparse_sym_rcm (f11yec) may be used prior to nag_sparse_sym_chol_fac (f11jac) and nag_sparse_sym_precon_ichol_solve (f11jbc) (see Section 10 in nag_sparse_sym_precon_ichol_solve (f11jbc)).

## 4  References

Pissanetsky S (1984) Sparse Matrix Technology Academic Press
Wai-Hung L and Sherman A H (1976) Comparative analysis of the Cuthill–McKee and the reverse Cuthill–McKee ordering algorithms for sparse matrices SIAM J. Numer. Anal. 13(2) 198–213

## 5  Arguments

1:    $\mathbf{n}$IntegerInput
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 1$.
2:    $\mathbf{nnz}$IntegerInput
On entry: the number of nonzero elements in the matrix $A$.
Constraint: ${\mathbf{nnz}}\ge 0$.
3:    $\mathbf{icolzp}\left[{\mathbf{n}}+1\right]$const IntegerInput
On entry: icolzp records the index into irowix which starts each new column.
Constraints:
• $1\le {\mathbf{icolzp}}\left[\mathit{i}-1\right]\le {\mathbf{nnz}}+1$, for $\mathit{i}=2,3,\dots ,{\mathbf{n}}$;
• ${\mathbf{icolzp}}\left[0\right]=1$;
• ${\mathbf{icolzp}}\left[{\mathbf{n}}\right]={\mathbf{nnz}}+1$, where ${\mathbf{icolzp}}\left[i-1\right]$ holds the position integer for the starts of the columns in irowix.
4:    $\mathbf{irowix}\left[{\mathbf{nnz}}\right]$const IntegerInput
On entry: the row indices corresponding to the nonzero elements in the matrix $A$.
Constraint: $1\le {\mathbf{irowix}}\left[\mathit{i}-1\right]\le {\mathbf{n}}$, for $\mathit{i}=1,2,\dots ,{\mathbf{nnz}}$.
5:    $\mathbf{lopts}\left[5\right]$const Nag_BooleanInput
On entry: the options to be used by nag_sparse_sym_rcm (f11yec).
${\mathbf{lopts}}\left[0\right]=\mathrm{Nag_TRUE}$
Row/column $i$ of the matrix $A$ will only be referenced if ${\mathbf{mask}}\left[i-1\right]\ne 0$, otherwise ${\mathbf{mask}}$ will be ignored.
${\mathbf{lopts}}\left[1\right]=\mathrm{Nag_TRUE}$
The final permutation will not be reversed, that is, the Cuthill–McKee ordering will be returned. The bandwidth of the non-reversed matrix will be the same but the profile will be the same or larger (see Wai-Hung and Sherman (1976)).
${\mathbf{lopts}}\left[2\right]=\mathrm{Nag_TRUE}$
The matrix $A$ will be checked for symmetrical sparsity pattern, otherwise not.
${\mathbf{lopts}}\left[3\right]=\mathrm{Nag_TRUE}$
The bandwidth and profile of the unpermuted matrix will be calculated, otherwise not.
${\mathbf{lopts}}\left[4\right]=\mathrm{Nag_TRUE}$
The bandwidth and profile of the permuted matrix will be calculated, otherwise not.
6:    $\mathbf{mask}\left[\mathit{dim}\right]$const IntegerInput
Note: the dimension, dim, of the array mask must be at least
• ${\mathbf{n}}$ when ${\mathbf{lopts}}\left[0\right]=\mathrm{Nag_TRUE}$;
• otherwise mask may be NULL.
On entry: mask is only referenced if ${\mathbf{lopts}}\left[0\right]$ is Nag_TRUE otherwise mask may be set to NULL. A value of ${\mathbf{mask}}\left[i-1\right]=0$ indicates that the node corresponding to row or column $i$ is not to be referenced. A value of ${\mathbf{mask}}\left[i-1\right]\ne 0$ indicates that the node corresponding to row or column $i$ is to be referenced. In particular, rows and columns not referenced will not be permuted.
7:    $\mathbf{perm}\left[{\mathbf{n}}\right]$IntegerOutput
On exit: this will contain the permutation vector that describes the permutation matrix $P$ for the reordering of the matrix $A$. The elements of the permutation matrix $P$ are zero except for the unit elements in row $i$ and column ${\mathbf{perm}}\left[i-1\right]$, $i=1,2,\dots n$.
8:    $\mathbf{info}\left[4\right]$IntegerOutput
On exit: statistics about the matrix $A$ and the permuted matrix. The quantities below are calculated using any masking in effect otherwise the value zero is returned.
${\mathbf{info}}\left[0\right]$
The bandwidth of the matrix $A$, if ${\mathbf{lopts}}\left[3\right]=\mathrm{Nag_TRUE}$.
${\mathbf{info}}\left[1\right]$
The profile of the matrix $A$, if ${\mathbf{lopts}}\left[3\right]=\mathrm{Nag_TRUE}$.
${\mathbf{info}}\left[2\right]$
The bandwidth of the permuted matrix $PA{P}^{\mathrm{T}}$, if ${\mathbf{lopts}}\left[4\right]=\mathrm{Nag_TRUE}$.
${\mathbf{info}}\left[3\right]$
The profile of the permuted matrix $PA{P}^{\mathrm{T}}$, if ${\mathbf{lopts}}\left[4\right]=\mathrm{Nag_TRUE}$.
9:    $\mathbf{fail}$NagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.2.1.2 in the Essential Introduction for further information.
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_INT
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 1$.
On entry, ${\mathbf{nnz}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{nnz}}\ge 1$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
An unexpected error has been triggered by this function. Please contact NAG.
See Section 3.6.6 in the Essential Introduction for further information.
NE_INVALID_CS
On entry, ${\mathbf{icolzp}}\left[0\right]=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{icolzp}}\left[0\right]=1$.
On entry, ${\mathbf{icolzp}}\left[{\mathbf{n}}\right]=〈\mathit{\text{value}}〉$ and ${\mathbf{nnz}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{icolzp}}\left[{\mathbf{n}}\right]={\mathbf{nnz}}+1$.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 3.6.5 in the Essential Introduction for further information.
NE_NONSYMM_MATRIX
On entry, the matrix $A$ is not symmetric.
Element $\left(〈\mathit{\text{value}}〉,〈\mathit{\text{value}}〉\right)$ has no symmetric element.
NE_SPARSE_COL
On entry, ${\mathbf{icolzp}}\left[〈\mathit{\text{value}}〉\right]=〈\mathit{\text{value}}〉$ and ${\mathbf{nnz}}=〈\mathit{\text{value}}〉$.
Constraint: $1\le {\mathbf{icolzp}}\left[i-1\right]\le {\mathbf{nnz}}$ for all $i$.
NE_SPARSE_ROW
On entry, ${\mathbf{irowix}}\left[〈\mathit{\text{value}}〉\right]=〈\mathit{\text{value}}〉$ and ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: $1\le {\mathbf{irowix}}\left[i-1\right]\le {\mathbf{n}}$ for all $i$.

Not applicable.

Not applicable.

## 9  Further Comments

The bandwidth for a matrix $A=\left({a}_{ij}\right)$ is defined as
 $b = maxij i-j , i,j=1,2,…,n​ s.t. ​aij≠0 .$
The profile is defined as
 $p = ∑ j=1 n bj , where ​ bj = max i i-j , i=1,2,…n ​ s.t. ​ aij≠0 .$

## 10  Example

This example reads the CCS representation of a real sparse matrix $A$ and calls nag_sparse_sym_rcm (f11yec) to reorder the rows and columns and displays the results.

### 10.1  Program Text

Program Text (f11yece.c)

### 10.2  Program Data

Program Data (f11yece.d)

### 10.3  Program Results

Program Results (f11yece.r)