# NAG CL Interfacef11mdc (direct_​real_​gen_​setup)

Settings help

CL Name Style:

## 1Purpose

f11mdc computes a column permutation suitable for $LU$ factorization (by f11mec) of a real sparse matrix in compressed column (Harwell–Boeing) format and applies it to the matrix. This function must be called prior to f11mec.

## 2Specification

 #include
 void f11mdc (Nag_ColumnPermutationType spec, Integer n, const Integer icolzp[], const Integer irowix[], Integer iprm[], NagError *fail)
The function may be called by the names: f11mdc, nag_sparse_direct_real_gen_setup or nag_superlu_column_permutation.

## 3Description

Given a sparse matrix in compressed column (Harwell–Boeing) format $A$ and a choice of column permutation schemes, the function computes those data structures that will be needed by the $LU$ factorization function f11mec and associated functions f11mmc, f11mfc and f11mhc. The column permutation choices are:
• original order (that is, no permutation);
• user-supplied permutation;
• a permutation, computed by the function, designed to minimize fill-in during the $LU$ factorization.
The algorithm for this computed permutation is based on the approximate minimum degree column ordering algorithm COLAMD. The computed permutation is not sensitive to the magnitude of the nonzero values of $A$.

## 4References

Amestoy P R, Davis T A and Duff I S (1996) An approximate minimum degree ordering algorithm SIAM J. Matrix Anal. Appl. 17 886–905
Gilbert J R and Larimore S I (2004) A column approximate minimum degree ordering algorithm ACM Trans. Math. Software 30,3 353–376
Gilbert J R, Larimore S I and Ng E G (2004) Algorithm 836: COLAMD, an approximate minimum degree ordering algorithm ACM Trans. Math. Software 30, 3 377–380

## 5Arguments

1: $\mathbf{spec}$Nag_ColumnPermutationType Input
On entry: indicates the permutation to be applied.
${\mathbf{spec}}=\mathrm{Nag_Sparse_Identity}$
The identity permutation is used (i.e., the columns are not permuted).
${\mathbf{spec}}=\mathrm{Nag_Sparse_User}$
The permutation in the iprm array is used, as supplied by you.
${\mathbf{spec}}=\mathrm{Nag_Sparse_Colamd}$
The permutation computed by the COLAMD algorithm is used
Constraint: ${\mathbf{spec}}=\mathrm{Nag_Sparse_Identity}$, $\mathrm{Nag_Sparse_User}$ or $\mathrm{Nag_Sparse_Colamd}$.
2: $\mathbf{n}$Integer Input
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.
3: $\mathbf{icolzp}\left[\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,\left({\mathbf{n}}+1\right)\right)\right]$const Integer Input
On entry: the new column index array of sparse matrix $A$. See Section 2.1.3 in the F11 Chapter Introduction.
4: $\mathbf{irowix}\left[\mathit{dim}\right]$const Integer Input
Note: the dimension, dim, of the array irowix must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,\left({\mathbf{icolzp}}\left[\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,\left({\mathbf{n}}+1\right)\right)-1\right]-1\right)\right)$.
On entry: ${\mathbf{irowix}}\left[i-1\right]$ contains the row index in $A$ for element $A\left(i\right)$. See Section 2.1.3 in the F11 Chapter Introduction.
5: $\mathbf{iprm}\left[\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,\left(7×{\mathbf{n}}\right)\right)\right]$Integer Input/Output
On entry: the first ${\mathbf{n}}$ entries contain the column permutation if supplied by the user. This will be used if ${\mathbf{spec}}=\mathrm{Nag_Sparse_User}$, and ignored otherwise. If used, it must consist of a permutation of all the integers in the range $\left[0,\left({\mathbf{n}}-1\right)\right]$, the leftmost column of the matrix $A$ denoted by $0$ and the rightmost by ${\mathbf{n}}-1$. Labelling columns in this way, ${\mathbf{iprm}}\left[i\right]=j$ means that column $i-1$ of $A$ is in position $j$ in $A{P}_{c}$, where ${P}_{r}A{P}_{c}=LU$ expresses the factorization to be performed.
On exit: The column permutation given or computed is returned in the second ${\mathbf{n}}$ entries. The rest of the array contains data structures that will be used by other functions in the suite. The function computes the column elimination tree for $A$ and a post-order permutation on the tree. It then compounds the iprm permutation given or computed by the COLAMD algorthm with the post-order permutation and this permutation is returned in the first ${\mathbf{n}}$ entries. This whole array is needed by the $LU$ factorization function f11mec and associated functions f11mfc, f11mhc and f11mmc and should be passed to them unchanged.
6: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_ALG_FAIL
COLAMD algorithm failed.
NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface 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 0$.
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.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_INVALID_PERM_COL
Incorrect column permutations in array iprm.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_SPARSE_COL
Incorrect specification of argument icolzp.
NE_SPARSE_ROW
Incorrect specification of argument irowix.

## 7Accuracy

Not applicable. This computation does not use floating-point numbers.

## 8Parallelism and Performance

f11mdc 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 function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

We recommend calling this function with ${\mathbf{spec}}=\mathrm{Nag_Sparse_Colamd}$ before calling f11mec. The COLAMD algorithm computes a sparsity-preserving permutation ${P}_{c}$ solely from the pattern of $A$ such that the $LU$ factorization ${P}_{r}A{P}_{c}=LU$ remains as sparse as possible, regardless of the subsequent choice of ${P}_{r}$. The algorithm takes advantage of the existence of super-columns (columns with the same sparsity pattern) to reduce running time.

## 10Example

This example computes a sparsity preserving column permutation for the $LU$ factorization of the matrix $A$, 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 ) .$

### 10.1Program Text

Program Text (f11mdce.c)

### 10.2Program Data

Program Data (f11mdce.d)

### 10.3Program Results

Program Results (f11mdce.r)