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_matop_real_gen_sparse_lu_reuse (f01bs)


    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example


nag_matop_real_gen_sparse_lu_reuse (f01bs) factorizes a real sparse matrix using the pivotal sequence previously obtained by nag_matop_real_gen_sparse_lu (f01br) when a matrix of the same sparsity pattern was factorized.


[a, w, rpmin, ifail] = f01bs(n, a, ivect, jvect, icn, ikeep, grow, idisp, 'nz', nz, 'licn', licn, 'eta', eta, 'abort', abort)
[a, w, rpmin, ifail] = nag_matop_real_gen_sparse_lu_reuse(n, a, ivect, jvect, icn, ikeep, grow, idisp, 'nz', nz, 'licn', licn, 'eta', eta, 'abort', abort)


nag_matop_real_gen_sparse_lu_reuse (f01bs) accepts as input a real sparse matrix of the same sparsity pattern as a matrix previously factorized by a call of nag_matop_real_gen_sparse_lu (f01br). It first applies to the matrix the same permutations as were used by nag_matop_real_gen_sparse_lu (f01br), both for permutation to block triangular form and for pivoting, and then performs Gaussian elimination to obtain the LU factorization of the diagonal blocks.
Extensive data checks are made; duplicated nonzeros can be accumulated.
The factorization is intended to be used by nag_linsys_real_sparse_fac_solve (f04ax) to solve sparse systems of linear equations Ax=b or ATx=b.
nag_matop_real_gen_sparse_lu_reuse (f01bs) is much faster than nag_matop_real_gen_sparse_lu (f01br) and in some applications it is expected that there will be many calls of nag_matop_real_gen_sparse_lu_reuse (f01bs) for each call of nag_matop_real_gen_sparse_lu (f01br).
The method is fully described in Duff (1977).
A more recent algorithm for the same calculation is provided by nag_sparse_direct_real_gen_lu (f11me).


Duff I S (1977) MA28 – a set of Fortran subroutines for sparse unsymmetric linear equations AERE Report R8730 HMSO


Compulsory Input Parameters

1:     n int64int32nag_int scalar
n, the order of the matrix A.
Constraint: n>0.
2:     alicn – double array
ai, for i=1,2,,nz, must contain the nonzero elements of the sparse matrix A. They can be in any order since nag_matop_real_gen_sparse_lu_reuse (f01bs) will reorder them.
3:     ivectnz int64int32nag_int array
4:     jvectnz int64int32nag_int array
ivecti and jvecti, for i=1,2,,nz, must contain the row index and the column index respectively of the nonzero element stored in ai.
5:     icnlicn int64int32nag_int array
icn contains, on entry, the same information as output by nag_matop_real_gen_sparse_lu (f01br). It must not be changed by you between a call of nag_matop_real_gen_sparse_lu_reuse (f01bs) and a call of nag_linsys_real_sparse_fac_solve (f04ax).
icn is used as internal workspace prior to being restored on exit and hence is unchanged.
6:     ikeep5×n int64int32nag_int array
The same indexing information about the factorization as output in ikeep by nag_matop_real_gen_sparse_lu (f01br).
You must not change ikeep between a call of nag_matop_real_gen_sparse_lu_reuse (f01bs) and subsequent calls to nag_linsys_real_sparse_fac_solve (f04ax).
7:     grow – logical scalar
If grow=true, then on exit w1 contains an estimate (an upper bound) of the increase in size of elements encountered during the factorization. If the matrix is well-scaled (see Further Comments), then a high value for w1 indicates that the LU factorization may be inaccurate and you should be wary of the results and perhaps increase the argument pivot for subsequent runs (see Accuracy).
8:     idisp2 int64int32nag_int array
idisp1 and idisp2 must be as output in idisp by the previous call of nag_matop_real_gen_sparse_lu (f01br).

Optional Input Parameters

1:     nz int64int32nag_int scalar
Default: the dimension of the arrays ivect, jvect. (An error is raised if these dimensions are not equal.)
The number of nonzero elements in the matrix A.
Constraint: nz>0.
2:     licn int64int32nag_int scalar
Default: the dimension of the arrays a, icn. (An error is raised if these dimensions are not equal.)
The dimension of the arrays a and icn. it should have the same value as it had for nag_matop_real_gen_sparse_lu (f01br).
Constraint: licnnz.
3:     eta – double scalar
Default: 0.0001
The relative pivot threshold below which an error diagnostic is provoked and ifail is set to ifail=7. If eta is greater than 1.0, then no check on pivot size is made.
4:     abort – logical scalar
Default: true
If abort=true, nag_matop_real_gen_sparse_lu_reuse (f01bs) exits immediately (with ifail=8) if it finds duplicate elements in the input matrix.
If abort=false, nag_matop_real_gen_sparse_lu_reuse (f01bs) proceeds using a value equal to the sum of the duplicate elements.
In either case details of each duplicate element are output on the current advisory message unit (see nag_file_set_unit_advisory (x04ab)), unless suppressed by the value of ifail on entry.

Output Parameters

1:     alicn – double array
The nonzero elements in the LU factorization. The array must not be changed by you between a call of nag_matop_real_gen_sparse_lu_reuse (f01bs) and a call of nag_linsys_real_sparse_fac_solve (f04ax).
2:     wn – double array
If grow=true, w1 contains an estimate (an upper bound) of the increase in size of elements encountered during the factorization (see grow); the rest of the array is used as workspace.
If grow=false, the array is not used.
3:     rpmin – double scalar
If eta is less than 1.0, then rpmin gives the smallest ratio of the pivot to the largest element in the row of the corresponding upper triangular factor thus monitoring the stability of the factorization. If rpmin is very small it may be advisable to perform a new factorization using nag_matop_real_gen_sparse_lu (f01br).
4:     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:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

On entry,n0.
On entry,nz0.
On entry,licn<nz.
On entry, an element of the input matrix has a row or column index (i.e., an element of ivect or jvect) outside the range 1 to n.
The input matrix is incompatible with the matrix factorized by the previous call of nag_matop_real_gen_sparse_lu (f01br) (see Further Comments).
The input matrix is numerically singular.
W  ifail=7
A very small pivot has been detected (see Arguments, eta). The factorization has been completed but is potentially unstable.
Duplicate elements have been found in the input matrix and the factorization has been abandoned (abort=true on entry).
An unexpected error has been triggered by this routine. Please contact NAG.
Your licence key may have expired or may not have been installed correctly.
Dynamic memory allocation failed.


The factorization obtained is exact for a perturbed matrix whose i,jth element differs from aij by less than 3ερmij where ε is the machine precision, ρ is the growth value returned in w1 if grow=true, and mij the number of Gaussian elimination operations applied to element i,j.
If ρ=w1 is very large or rpmin is very small, then a fresh call of nag_matop_real_gen_sparse_lu (f01br) is recommended.

Further Comments

If you have a sequence of problems with the same sparsity pattern then nag_matop_real_gen_sparse_lu_reuse (f01bs) is recommended after nag_matop_real_gen_sparse_lu (f01br) has been called for one such problem. It is typically 4 to 7 times faster but is potentially unstable since the previous pivotal sequence is used. Further details on timing are given in the document for nag_matop_real_gen_sparse_lu (f01br).
If growth estimation is performed (grow=true), then the time increases by between 5% and 10%. Pivot size monitoring (eta1.0) involves a similar overhead.
We normally expect this function to be entered with a matrix having the same pattern of nonzeros as was earlier presented to nag_matop_real_gen_sparse_lu (f01br). However there is no record of this pattern, but rather a record of the pattern including all fill-ins. Therefore we permit additional nonzeros in positions corresponding to fill-ins.
If singular matrices are being treated then it is also required that the present matrix be sufficiently like the previous one for the same permutations to be suitable for factorization with the same set of zero pivots.


This example factorizes the real sparse matrices
5 0 0 0 0 0 0 2 -1 2 0 0 0 0 3 0 0 0 -2 0 0 1 1 0 -1 0 0 -1 2 -3 -1 -1 0 0 0 6  
10 0 0 0 0 0 0 12 -3 -1 0 0 0 0 15 0 0 0 -2 0 0 10 -1 0 -1 0 0 -5 1 -1 -1 -2 0 0 0 6 .  
This example program simply prints the values of w1 and rpmin returned by nag_matop_real_gen_sparse_lu_reuse (f01bs). Normally the calls of nag_matop_real_gen_sparse_lu (f01br) and nag_matop_real_gen_sparse_lu_reuse (f01bs) would be followed by calls of nag_linsys_real_sparse_fac_solve (f04ax).
function f01bs_example

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

% Define sparse matrix A
n  = int64(6);
nz = int64(15);
z  = int64(15);
a  = zeros(150,1);
a(1:15)   = [5;  2;-1;2;  3;  -2;1;1;  -1;-1;2;-3;  -1;-1;6];

irn = zeros(75,1,'int64');
icn = zeros(150,1,'int64');
irn(1:15) = [int64(1); 2;2;2; 3; 4;4;4; 5;5;5;5; 6;6;6];
icn(1:15) = [int64(1); 2;3;4; 3; 1;4;5; 1;4;5;6; 1;2;6];

abort     = [true;     true;     false;     true];

% second matrix has same sparsity
ivect = irn(1:15);
jvect = icn(1:15);
grow = true;

[a, irn, icn, ikeep, w, idisp, ifail] = ...
f01br( ...
       n, nz, a, irn, icn, abort);

fprintf('For first matrix:\nValue of w(1)  = %7.4f\n\n', w(1));

% overwrite nz elements of A by second matrix with same sparsity
a(1:15) = [10; 12;-3;-1; 15; -2;10;-1; -1;-5;1;-1; -1;-2;6 ];
eta = 0.1;
[a, w, rpmin, ifail] = f01bs( ...
                              n, a, ivect, jvect, icn, ikeep, grow, idisp, ...

fprintf('For second matrix:\nValue of w(1)  = %7.4f\n\n', w(1));
fprintf('Value of rpmin = %7.4f\n', rpmin);

f01bs example results

For first matrix:
Value of w(1)  = 18.0000

For second matrix:
Value of w(1)  = 51.0000

Value of rpmin =  0.1000

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