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)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_sparse_direct_real_gen_setup (f11md) computes a column permutation suitable for 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 A and a choice of column permutation schemes, the function computes those data structures that will be needed by the 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 A.

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'
The identity permutation is used (i.e., the columns are not permuted).
spec='U'
The permutation in the iprm array is used, as supplied by you.
spec='M'
The permutation computed by the COLAMD algorithm is used
Constraint: spec='N', 'U' or 'M'.
2:     n int64int32nag_int scalar
n, the order of the matrix A.
Constraint: n0.
3:     icolzp: int64int32nag_int array
The dimension of the array icolzp must be at least n+1
icolzpi contains the index in A of the start of a new column. See Compressed column storage (CCS) format in the F11 Chapter Introduction.
4:     irowix: int64int32nag_int array
The dimension of the array irowix must be at least icolzpn+1-1, the number of nonzeros of the sparse matrix A
irowixi contains the row index in A for element Ai. See Compressed column storage (CCS) format in the F11 Chapter Introduction.
5:     iprm7×n int64int32nag_int array
The first n entries contain the column permutation supplied by you. This will be used if spec='U', and ignored otherwise. If used, it must consist of a permutation of all the integers in the range 0,n-1, the leftmost column of the matrix A denoted by 0 and the rightmost by n-1. Labelling columns in this way, iprmi=j means that column i-1 of A is in position j in APc, where Pr A Pc=LU  expresses the factorization to be performed.

Optional Input Parameters

None.

Output Parameters

1:     iprm7×n int64int32nag_int array
A new permutation is returned in the first n entries. The rest of the array contains data structures that will be used by other functions. 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. This array is needed by the 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=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
   ifail=1
Constraint: n0.
On entry, spec=_.
Constraint: spec='N', 'U' or 'M'.
   ifail=2
Incorrect column permutations in array iprm.
   ifail=3
COLAMD algorithm failed.
   ifail=4
Incorrect specification of argument icolzp.
   ifail=5
Incorrect specification of argument irowix.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

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

Further Comments

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

Example

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 .  
function f11md_example


fprintf('f11md example results\n\n');

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)));


f11md example results


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–2015