hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_sparse_direct_real_gen_setup (f11md)

Purpose

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

Syntax

[iprm, ifail] = f11md(spec, n, icolzp, irowix, iprm)
[iprm, ifail] = nag_sparse_direct_real_gen_setup(spec, n, icolzp, irowix, iprm)

Description

Given a sparse matrix in compressed column (Harwell–Boeing) format AA and a choice of column permutation schemes, the function computes those data structures that will be needed by the LU LU  factorization function nag_sparse_direct_real_gen_lu (f11me) and associated functions nag_sparse_direct_real_gen_diag (f11mm), nag_sparse_direct_real_gen_solve (f11mf) and nag_sparse_direct_real_gen_refine (f11mh). The column permutation choices are:
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 AA.

References

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

Parameters

Compulsory Input Parameters

1:     spec – string (length ≥ 1)
Indicates the permutation to be applied.
spec = 'N'spec='N'
The identity permutation is used (i.e., the columns are not permuted).
spec = 'U'spec='U'
The permutation in the iprm array is used, as supplied by you.
spec = 'M'spec='M'
The permutation computed by the COLAMD algorithm is used
Constraint: spec = 'N'spec='N', 'U''U' or 'M''M'.
2:     n – int64int32nag_int scalar
nn, the order of the matrix AA.
Constraint: n0n0.
3:     icolzp( : :) – int64int32nag_int array
Note: the dimension of the array icolzp must be at least n + 1n+1.
icolzp(i)icolzpi contains the index in AA of the start of a new column. See Section [Compressed column storage (CCS) format] in the F11 Chapter Introduction.
4:     irowix( : :) – int64int32nag_int array
Note: the dimension of the array irowix must be at least icolzp(n + 1)1icolzpn+1-1, the number of nonzeros of the sparse matrix AA.
irowix(i)irowixi contains the row index in AA for element A(i)A(i). See Section [Compressed column storage (CCS) format] in the F11 Chapter Introduction.
5:     iprm(7 × n7×n) – int64int32nag_int array
The first nn entries contain the column permutation supplied by you. This will be used if spec = 'U'spec='U', and ignored otherwise. If used, it must consist of a permutation of all the integers in the range [0,(n1)][0,(n-1)], the leftmost column of the matrix AA denoted by 00 and the rightmost by n1n-1. Labelling columns in this way, iprm(i) = jiprmi=j means that column i1i-1 of AA is in position jj in APcAPc, where Pr A Pc = LU Pr A Pc=LU  expresses the factorization to be performed.

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     iprm(7 × n7×n) – int64int32nag_int array
A new permutation is returned in the first nn entries. The rest of the array contains data structures that will be used by other functions. The function computes the column elimination tree for AA 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. This array is needed by the LU LU factorization function nag_sparse_direct_real_gen_lu (f11me) and associated functions nag_sparse_direct_real_gen_solve (f11mf), nag_sparse_direct_real_gen_refine (f11mh) and nag_sparse_direct_real_gen_diag (f11mm) and should be passed to them unchanged.
2:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,spec'N'spec'N', 'U''U' or 'M''M',
orn < 0n<0.
  ifail = 2ifail=2
On entry, spec = 'U'spec='U', but iprm does not represent a valid permutation of the integers in [0,(n1)][0,(n-1)]. An input value of iprm is either out of range or repeated.
  ifail = 3ifail=3
Unspecified failure of the COLAMD algorithm. This should not happen and should be reported to NAG.
  ifail = 4ifail=4
On entry, the array icolzp failed to satisfy the following constraints:
  ifail = 5ifail=5
On entry, the array irowix failed to satisfy the following constraints:
  ifail = 301ifail=301
Unable to allocate required internal workspace.

Accuracy

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

Further Comments

We recommend calling this function with spec = 'M'spec='M' before calling nag_sparse_direct_real_gen_lu (f11me). The COLAMD algorithm computes a sparsity-preserving permutation PcPc solely from the pattern of AA such that the LU LU  factorization Pr A Pc = LU Pr A Pc = LU  remains as sparse as possible, regardless of the subsequent choice of PrPr. The algorithm takes advantage of the existence of super-columns (columns with the same sparsity pattern) to reduce running time.

Example

function nag_sparse_direct_real_gen_setup_example
n = int64(5);
icolzp = [int64(1); 3; 5; 7; 9; 12];
irowix = [int64(1); 3; 1; 5; 2; 3; 2; 4; 3; 4; 5];
iprm = zeros(1, 7*n, 'int64');
% Calculate COLAMD permutation
spec = 'M';
[iprm, ifail] = nag_sparse_direct_real_gen_setup(spec, n, icolzp, irowix, iprm);
fprintf('\nCOLAMD Permutation\n');
disp(int2str(iprm(1:n)));

% Calculate user permutation
spec = 'U';
iprm(1:n)= [4, 3, 2, 1, 0];
[iprm, ifail] = nag_sparse_direct_real_gen_setup(spec, n, icolzp, irowix, iprm);
fprintf('\nUser Permutation\n');
disp(int2str(iprm(1:n)));

% Calculate natural permutation
spec = 'N';
[iprm, ifail] = nag_sparse_direct_real_gen_setup(spec, n, icolzp, irowix, iprm);
fprintf('\nNatural Permutation\n');
disp(int2str(iprm(1:n)));
 

COLAMD Permutation
1  0  4  3  2

User Permutation
4  3  2  1  0

Natural Permutation
0  1  2  3  4

function f11md_example
n = int64(5);
icolzp = [int64(1); 3; 5; 7; 9; 12];
irowix = [int64(1); 3; 1; 5; 2; 3; 2; 4; 3; 4; 5];
iprm = zeros(1, 7*n, 'int64');
% Calculate COLAMD permutation
spec = 'M';
[iprm, ifail] = f11md(spec, n, icolzp, irowix, iprm);
fprintf('\nCOLAMD Permutation\n');
disp(int2str(iprm(1:n)));

% Calculate user permutation
spec = 'U';
iprm(1:n)= [4, 3, 2, 1, 0];
[iprm, ifail] = f11md(spec, n, icolzp, irowix, iprm);
fprintf('\nUser Permutation\n');
disp(int2str(iprm(1:n)));

% Calculate natural permutation
spec = 'N';
[iprm, ifail] = f11md(spec, n, icolzp, irowix, iprm);
fprintf('\nNatural Permutation\n');
disp(int2str(iprm(1:n)));
 

COLAMD Permutation
1  0  4  3  2

User Permutation
4  3  2  1  0

Natural Permutation
0  1  2  3  4


PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013