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_solve (f11mf)

Purpose

nag_sparse_direct_real_gen_solve (f11mf) solves a real sparse system of linear equations with multiple right-hand sides given an LU LU  factorization of the sparse matrix computed by nag_sparse_direct_real_gen_lu (f11me).

Syntax

[b, ifail] = f11mf(trans, iprm, il, lval, iu, uval, b, 'n', n, 'nrhs_p', nrhs_p)
[b, ifail] = nag_sparse_direct_real_gen_solve(trans, iprm, il, lval, iu, uval, b, 'n', n, 'nrhs_p', nrhs_p)

Description

nag_sparse_direct_real_gen_solve (f11mf) solves a real system of linear equations with multiple right-hand sides AX = BAX=B or ATX = BATX=B, according to the value of the parameter trans, where the matrix factorization Pr A Pc = LU Pr A Pc = LU  corresponds to an LU LU  decomposition of a sparse matrix stored in compressed column (Harwell–Boeing) format, as computed by nag_sparse_direct_real_gen_lu (f11me).
In the above decomposition LL is a lower triangular sparse matrix with unit diagonal elements and UU is an upper triangular sparse matrix; PrPr and PcPc are permutation matrices.

References

None.

Parameters

Compulsory Input Parameters

1:     trans – string (length ≥ 1)
Specifies whether AX = BAX=B or ATX = BATX=B is solved.
trans = 'N'trans='N'
AX = BAX=B is solved.
trans = 'T'trans='T'
ATX = BATX=B is solved.
Constraint: trans = 'N'trans='N' or 'T''T'.
2:     iprm(7 × n7×n) – int64int32nag_int array
The column permutation which defines PcPc, the row permutation which defines PrPr, plus associated data structures as computed by nag_sparse_direct_real_gen_lu (f11me).
3:     il( : :) – int64int32nag_int array
Note: the dimension of the array il must be at least as large as the dimension of the array of the same name in nag_sparse_direct_real_gen_lu (f11me).
Records the sparsity pattern of matrix LL as computed by nag_sparse_direct_real_gen_lu (f11me).
4:     lval( : :) – double array
Note: the dimension of the array lval must be at least as large as the dimension of the array of the same name in nag_sparse_direct_real_gen_lu (f11me).
Records the nonzero values of matrix LL and some nonzero values of matrix UU as computed by nag_sparse_direct_real_gen_lu (f11me).
5:     iu( : :) – int64int32nag_int array
Note: the dimension of the array iu must be at least as large as the dimension of the array of the same name in nag_sparse_direct_real_gen_lu (f11me).
Records the sparsity pattern of matrix UU as computed by nag_sparse_direct_real_gen_lu (f11me).
6:     uval( : :) – double array
Note: the dimension of the array uval must be at least as large as the dimension of the array of the same name in nag_sparse_direct_real_gen_lu (f11me).
Records some nonzero values of matrix UU as computed by nag_sparse_direct_real_gen_lu (f11me).
7:     b(ldb, : :) – double array
The first dimension of the array b must be at least max (1,n)max(1,n)
The second dimension of the array must be at least max (1,nrhs)max(1,nrhs)
The nn by nrhsnrhs right-hand side matrix BB.

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The first dimension of the array b.
nn, the order of the matrix AA.
Constraint: n0n0.
2:     nrhs_p – int64int32nag_int scalar
Default: The second dimension of the array b.
nrhsnrhs, the number of right-hand sides in BB.
Constraint: nrhs0nrhs0.

Input Parameters Omitted from the MATLAB Interface

ldb

Output Parameters

1:     b(ldb, : :) – double array
The first dimension of the array b will be max (1,n)max(1,n)
The second dimension of the array will be max (1,nrhs)max(1,nrhs)
ldbmax (1,n)ldbmax(1,n).
The nn by nrhsnrhs solution matrix XX.
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,trans'N'trans'N' or 'T''T',
orn < 0n<0,
ornrhs < 0nrhs<0,
orldb < max (1,n)ldb<max(1,n).
  ifail = 2ifail=2
Ill-defined row permutation in array iprmiprm. Internal checks have revealed that the iprmiprm array is corrupted.
  ifail = 3ifail=3
Ill-defined column permutations in array iprmiprm. Internal checks have revealed that the iprmiprm array is corrupted.
  ifail = 301ifail=301
Unable to allocate required internal workspace.

Accuracy

For each right-hand side vector bb, the computed solution xx is the exact solution of a perturbed system of equations (A + E)x = b(A+E)x=b, where
|E|c(n)ε|L||U|,
|E|c(n)ε|L||U|,
c(n)c(n) is a modest linear function of nn, and εε is the machine precision, when partial pivoting is used.
If x^ is the true solution, then the computed solution xx satisfies a forward error bound of the form
( x )/( x ) c(n)cond(A,x)ε
x-x^ x c(n)cond(A,x)ε
where cond(A,x) = |A1||A||x| / xcond(A) = |A1||A|κ (A)cond(A,x)= |A-1| |A| |x| / xcond(A)= |A-1| |A| κ (A). Note that cond(A,x)cond(A,x) can be much smaller than cond(A)cond(A), and cond(AT)cond(AT) can be much larger (or smaller) than cond(A)cond(A).
Forward and backward error bounds can be computed by calling nag_sparse_direct_real_gen_refine (f11mh), and an estimate for κ(A)κ(A) can be obtained by calling nag_sparse_direct_real_gen_cond (f11mg).

Further Comments

nag_sparse_direct_real_gen_solve (f11mf) may be followed by a call to nag_sparse_direct_real_gen_refine (f11mh) to refine the solution and return an error estimate.

Example

function nag_sparse_direct_real_gen_solve_example
n = int64(5);
nz = int64(11);
icolzp = [int64(1); 3; 5; 7; 9; 12];
irowix = [int64(1); 3; 1; 5; 2; 3; 2; 4; 3; 4; 5];
a = [2; 4; 1; -2; 1; 1; -1; 1; 1; 2; 3];
b = [  1.56,  3.12;
      -0.25, -0.50;
       3.60,  7.20;
       1.33,  2.66;
       0.52,  1.04];
iprm = zeros(1, 7*n, 'int64');
spec = 'M';
thresh = 1;
nzlmx = int64(8*nz);
nzlumx = int64(8*nz);
nzumx = int64(8*nz);
trans = 'N';

% Calculate COLAMD permutation
[iprm, ifail] = nag_sparse_direct_real_gen_setup(spec, n, icolzp, irowix, iprm);

% Factorise
[iprm, nzlumx, il, lval, iu, uval, nnzl, nnzu, flop, ifail] = ...
    nag_sparse_direct_real_gen_lu(n, irowix, a, iprm, thresh, nzlmx, nzlumx, nzumx);

% Solve
[b, ifail] = nag_sparse_direct_real_gen_solve(trans, iprm, il, lval, iu, uval, b)
 

b =

    0.7000    1.4000
    0.1600    0.3200
    0.5200    1.0400
    0.7700    1.5400
    0.2800    0.5600


ifail =

                    0


function f11mf_example
n = int64(5);
nz = int64(11);
icolzp = [int64(1); 3; 5; 7; 9; 12];
irowix = [int64(1); 3; 1; 5; 2; 3; 2; 4; 3; 4; 5];
a = [2; 4; 1; -2; 1; 1; -1; 1; 1; 2; 3];
b = [  1.56,  3.12;
      -0.25, -0.50;
       3.60,  7.20;
       1.33,  2.66;
       0.52,  1.04];
iprm = zeros(1, 7*n, 'int64');
spec = 'M';
thresh = 1;
nzlmx = int64(8*nz);
nzlumx = int64(8*nz);
nzumx = int64(8*nz);
trans = 'N';

% Calculate COLAMD permutation
[iprm, ifail] = f11md(spec, n, icolzp, irowix, iprm);

% Factorise
[iprm, nzlumx, il, lval, iu, uval, nnzl, nnzu, flop, ifail] = ...
    f11me(n, irowix, a, iprm, thresh, nzlmx, nzlumx, nzumx);

% Solve
[b, ifail] = f11mf(trans, iprm, il, lval, iu, uval, b)
 

b =

    0.7000    1.4000
    0.1600    0.3200
    0.5200    1.0400
    0.7700    1.5400
    0.2800    0.5600


ifail =

                    0



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