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_lapack_dgesvx (f07ab)

Purpose

nag_lapack_dgesvx (f07ab) uses the LULU factorization to compute the solution to a real system of linear equations
AX = B   or   ATX = B ,
AX=B   or   ATX=B ,
where AA is an nn by nn matrix and XX and BB are nn by rr matrices. Error bounds on the solution and a condition estimate are also provided.

Syntax

[a, af, ipiv, equed, r, c, b, x, rcond, ferr, berr, work, info] = f07ab(fact, trans, a, af, ipiv, equed, r, c, b, 'n', n, 'nrhs_p', nrhs_p)
[a, af, ipiv, equed, r, c, b, x, rcond, ferr, berr, work, info] = nag_lapack_dgesvx(fact, trans, a, af, ipiv, equed, r, c, b, 'n', n, 'nrhs_p', nrhs_p)

Description

nag_lapack_dgesvx (f07ab) performs the following steps:
  1. Equilibration
    The linear system to be solved may be badly scaled. However, the system can be equilibrated as a first stage by setting fact = 'E'fact='E'. In this case, real scaling factors are computed and these factors then determine whether the system is to be equilibrated. Equilibrated forms of the systems AX = B AX=B  and ATX = B ATX=B  are
    (DRADC) (DC1X) = DR B
    ( DR A DC ) ( DC-1X ) = DR B
    and
    (DRADC)T (DR1X) = DC B ,
    ( DR A DC )T ( DR-1 X ) = DC B ,
    respectively, where DR DR  and DC DC  are diagonal matrices, with positive diagonal elements, formed from the computed scaling factors.
    When equilibration is used, AA will be overwritten by DR A DC DR A DC  and BB will be overwritten by DR B DR B  (or DC B DC B  when the solution of ATX = B ATX=B  is sought).
  2. Factorization
    The matrix AA, or its scaled form, is copied and factored using the LULU decomposition
    A = PLU ,
    A=PLU ,
    where PP is a permutation matrix, LL is a unit lower triangular matrix, and UU is upper triangular.
    This stage can be by-passed when a factored matrix (with scaled matrices and scaling factors) are supplied; for example, as provided by a previous call to nag_lapack_dgesvx (f07ab) with the same matrix AA.
  3. Condition Number Estimation
    The LULU factorization of AA determines whether a solution to the linear system exists. If some diagonal element of UU is zero, then UU is exactly singular, no solution exists and the function returns with a failure. Otherwise the factorized form of AA is used to estimate the condition number of the matrix AA. If the reciprocal of the condition number is less than machine precision then a warning code is returned on final exit.
  4. Solution
    The (equilibrated) system is solved for XX ( DC1X DC-1X  or DR1X DR-1X ) using the factored form of AA ( DRADC DRADC ).
  5. Iterative Refinement
    Iterative refinement is applied to improve the computed solution matrix and to calculate error bounds and backward error estimates for the computed solution.
  6. Construct Solution Matrix XX
    If equilibration was used, the matrix XX is premultiplied by DC DC  (if trans = 'N'trans='N') or DR DR  (if trans = 'T'trans='T' or 'C''C') so that it solves the original system before equilibration.

References

Anderson E, Bai Z, Bischof C, Blackford S, Demmel J, Dongarra J J, Du Croz J J, Greenbaum A, Hammarling S, McKenney A and Sorensen D (1999) LAPACK Users' Guide (3rd Edition) SIAM, Philadelphia http://www.netlib.org/lapack/lug
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
Higham N J (2002) Accuracy and Stability of Numerical Algorithms (2nd Edition) SIAM, Philadelphia

Parameters

Compulsory Input Parameters

1:     fact – string (length ≥ 1)
Specifies whether or not the factorized form of the matrix AA is supplied on entry, and if not, whether the matrix AA should be equilibrated before it is factorized.
fact = 'F'fact='F'
af and ipiv contain the factorized form of AA. If equed'N'equed'N', the matrix AA has been equilibrated with scaling factors given by r and c. a, af and ipiv are not modified.
fact = 'N'fact='N'
The matrix AA will be copied to af and factorized.
fact = 'E'fact='E'
The matrix AA will be equilibrated if necessary, then copied to af and factorized.
Constraint: fact = 'F'fact='F', 'N''N' or 'E''E'.
2:     trans – string (length ≥ 1)
Specifies the form of the system of equations.
trans = 'N'trans='N'
AX = BAX=B (No transpose).
trans = 'T'trans='T' or 'C''C'
ATX = BATX=B (Transpose).
Constraint: trans = 'N'trans='N', 'T''T' or 'C''C'.
3:     a(lda, : :) – double array
The first dimension of the array a must be at least max (1,n)max(1,n)
The second dimension of the array must be at least max (1,n)max(1,n)
The nn by nn matrix AA.
If fact = 'F'fact='F' and equed'N'equed'N', a must have been equilibrated by the scaling factors in r and/or c.
4:     af(ldaf, : :) – double array
The first dimension of the array af must be at least max (1,n)max(1,n)
The second dimension of the array must be at least max (1,n)max(1,n)
If fact = 'F'fact='F', af contains the factors LL and UU from the factorization A = PLUA=PLU as computed by nag_lapack_dgetrf (f07ad). If equed'N'equed'N', af is the factorized form of the equilibrated matrix AA.
If fact = 'N'fact='N' or 'E''E', af need not be set.
5:     ipiv( : :) – int64int32nag_int array
Note: the dimension of the array ipiv must be at least max (1,n)max(1,n).
If fact = 'F'fact='F', ipiv contains the pivot indices from the factorization A = PLUA=PLU as computed by nag_lapack_dgetrf (f07ad); at the iith step row ii of the matrix was interchanged with row ipiv(i)ipivi. ipiv(i) = iipivi=i indicates a row interchange was not required.
If fact = 'N'fact='N' or 'E''E', ipiv need not be set.
6:     equed – string (length ≥ 1)
If fact = 'N'fact='N' or 'E''E', equed need not be set.
If fact = 'F'fact='F', equed must specify the form of the equilibration that was performed as follows:
  • if equed = 'N'equed='N', no equilibration;
  • if equed = 'R'equed='R', row equilibration, i.e., AA has been premultiplied by DRDR;
  • if equed = 'C'equed='C', column equilibration, i.e., AA has been postmultiplied by DCDC;
  • if equed = 'B'equed='B', both row and column equilibration, i.e., AA has been replaced by DRADCDRADC.
Constraint: if fact = 'F'fact='F', equed = 'N'equed='N', 'R''R', 'C''C' or 'B''B'.
7:     r( : :) – double array
Note: the dimension of the array r must be at least max (1,n)max(1,n).
If fact = 'N'fact='N' or 'E''E', r need not be set.
If fact = 'F'fact='F' and equed = 'R'equed='R' or 'B''B', r must contain the row scale factors for AA, DRDR; each element of r must be positive.
8:     c( : :) – double array
Note: the dimension of the array c must be at least max (1,n)max(1,n).
If fact = 'N'fact='N' or 'E''E', c need not be set.
If fact = 'F'fact='F' or equed = 'C'equed='C' or 'B''B', c must contain the column scale factors for AA, DCDC; each element of c must be positive.
9:     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 rr right-hand side matrix BB.

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The first dimension of the arrays a, af, b The second dimension of the arrays a, af, ipiv, r, c.
nn, the number of linear equations, i.e., the order of the matrix AA.
Constraint: n0n0.
2:     nrhs_p – int64int32nag_int scalar
Default: The second dimension of the array b.
rr, the number of right-hand sides, i.e., the number of columns of the matrix BB.
Constraint: nrhs0nrhs0.

Input Parameters Omitted from the MATLAB Interface

lda ldaf ldb ldx iwork

Output Parameters

1:     a(lda, : :) – double array
The first dimension of the array a will be max (1,n)max(1,n)
The second dimension of the array will be max (1,n)max(1,n)
ldamax (1,n)ldamax(1,n).
If fact = 'F'fact='F' or 'N''N', or if fact = 'E'fact='E' and equed = 'N'equed='N', a is not modified.
If fact = 'E'fact='E' or equed'N'equed'N', AA is scaled as follows:
  • if equed = 'R'equed='R', A = DRAA=DRA;
  • if equed = 'C'equed='C', A = ADCA=ADC;
  • if equed = 'B'equed='B', A = DRADCA=DRADC.
2:     af(ldaf, : :) – double array
The first dimension of the array af will be max (1,n)max(1,n)
The second dimension of the array will be max (1,n)max(1,n)
ldafmax (1,n)ldafmax(1,n).
If fact = 'N'fact='N', af returns the factors LL and UU from the factorization A = PLUA=PLU of the original matrix AA.
If fact = 'E'fact='E', af returns the factors LL and UU from the factorization A = PLUA=PLU of the equilibrated matrix AA (see the description of a for the form of the equilibrated matrix).
If fact = 'F'fact='F', af is unchanged from entry.
3:     ipiv( : :) – int64int32nag_int array
Note: the dimension of the array ipiv must be at least max (1,n)max(1,n).
If fact = 'N'fact='N', ipiv contains the pivot indices from the factorization A = PLUA=PLU of the original matrix AA.
If fact = 'E'fact='E', ipiv contains the pivot indices from the factorization A = PLUA=PLU of the equilibrated matrix AA.
If fact = 'F'fact='F', ipiv is unchanged from entry.
4:     equed – string (length ≥ 1)
If fact = 'F'fact='F', equed is unchanged from entry.
Otherwise, if no constraints are violated, equed specifies the form of equilibration that was performed as specified above.
5:     r( : :) – double array
Note: the dimension of the array r must be at least max (1,n)max(1,n).
If fact = 'F'fact='F', r is unchanged from entry.
Otherwise, if no constraints are violated and equed = 'R'equed='R' or 'B''B', r contains the row scale factors for AA, DRDR, such that AA is multiplied on the left by DRDR; each element of r is positive.
6:     c( : :) – double array
Note: the dimension of the array c must be at least max (1,n)max(1,n).
If fact = 'F'fact='F', c is unchanged from entry.
Otherwise, if no constraints are violated and equed = 'C'equed='C' or 'B''B', c contains the row scale factors for AA, DCDC; each element of c is positive.
7:     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).
If equed = 'N'equed='N', b is not modified.
If trans = 'N'trans='N' and equed = 'R'equed='R' or 'B''B', b stores DRBDRB.
If trans = 'T'trans='T' or 'C''C' and equed = 'C'equed='C' or 'B''B', b stores DCBDCB.
8:     x(ldx, : :) – double array
The first dimension of the array x will be max (1,n)max(1,n)
The second dimension of the array will be max (1,nrhs)max(1,nrhs)
ldxmax (1,n)ldxmax(1,n).
If INFO = 0INFO=0 or n + 1n+1, the nn by rr solution matrix XX to the original system of equations. Note that the arrays AA and BB are modified on exit if equed'N'equed'N', and the solution to the equilibrated system is DC1XDC-1X if trans = 'N'trans='N' and equed = 'C'equed='C' or 'B''B', or DR1XDR-1X if trans = 'T'trans='T' or 'C''C' and equed = 'R'equed='R' or 'B''B'.
9:     rcond – double scalar
If no constraints are violated, an estimate of the reciprocal condition number of the matrix AA (after equilibration if that is performed), computed as rcond = 1.0 / (A1A11)rcond=1.0/(A1 A-11 ).
10:   ferr(nrhs_p) – double array
If INFO = 0INFO=0 or n + 1n+1, an estimate of the forward error bound for each computed solution vector, such that jxj / xjferr(j)x^j-xj/xjferrj where jx^j is the jjth column of the computed solution returned in the array x and xjxj is the corresponding column of the exact solution XX. The estimate is as reliable as the estimate for rcond, and is almost always a slight overestimate of the true error.
11:   berr(nrhs_p) – double array
If INFO = 0INFO=0 or n + 1n+1, an estimate of the component-wise relative backward error of each computed solution vector jx^j (i.e., the smallest relative change in any element of AA or BB that makes jx^j an exact solution).
12:   work(max (1,4 × n)max(1,4×n)) – double array
work(1)work1 contains the reciprocal pivot growth factor A / UA/U. The ‘max absolute element’ norm is used. If work(1)work1 is much less than 11, then the stability of the LULU factorization of the (equilibrated) matrix AA could be poor. This also means that the solution x, condition estimate rcond, and forward error bound ferr could be unreliable. If the factorization fails with INFO > 0andINFOnINFO>0andINFOn, then work(1)work1 contains the reciprocal pivot growth factor for the leading info columns of AA.
13:   info – int64int32nag_int scalar
info = 0info=0 unless the function detects an error (see Section [Error Indicators and Warnings]).

Error Indicators and Warnings

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

  info = iinfo=-i
If info = iinfo=-i, parameter ii had an illegal value on entry. The parameters are numbered as follows:
1: fact, 2: trans, 3: n, 4: nrhs_p, 5: a, 6: lda, 7: af, 8: ldaf, 9: ipiv, 10: equed, 11: r, 12: c, 13: b, 14: ldb, 15: x, 16: ldx, 17: rcond, 18: ferr, 19: berr, 20: work, 21: iwork, 22: info.
It is possible that info refers to a parameter that is omitted from the MATLAB interface. This usually indicates that an error in one of the other input parameters has caused an incorrect value to be inferred.
W INFO > 0andINFONINFO>0andINFON
If info = iinfo=i, uiiuii is exactly zero. The factorization has been completed, but the factor UU is exactly singular, so the solution and error bounds could not be computed. rcond = 0.0rcond=0.0 is returned.
W INFO = N + 1INFO=N+1
The triangular matrix UU is nonsingular, but rcond is less than machine precision, meaning that the matrix is singular to working precision. Nevertheless, the solution and error bounds are computed because there are a number of situations where the computed solution can be more accurate than the value of rcond would suggest.

Accuracy

For each right-hand side vector bb, the computed solution x^ is the exact solution of a perturbed system of equations (A + E) = b(A+E)x^=b, where
|E|c(n)εP|L||U| ,
|E|c(n)εP|L||U| ,
c(n)c(n) is a modest linear function of nn, and εε is the machine precision. See Section 9.3 of Higham (2002) for further details.
If xx is the true solution, then the computed solution x^ satisfies a forward error bound of the form
( x )/( ) wc cond(A,,b)
x-x^ x^ wc cond(A,x^,b)
where cond(A,,b) = |A1|(|A||| + |b|) / cond(A) = |A1||A|κ (A) cond(A,x^,b) = |A-1| ( |A| |x^| + |b| ) / x^ cond(A) = |A-1| |A| κ (A). If x^  is the j j th column of X X , then wc wc  is returned in berr(j) berrj  and a bound on x / x - x^ / x^  is returned in ferr(j) ferrj . See Section 4.4 of Anderson et al. (1999) for further details.

Further Comments

The factorization of A A  requires approximately (2/3) n3 23 n3  floating point operations.
Estimating the forward error involves solving a number of systems of linear equations of the form Ax = bAx=b or ATx = bATx=b; the number is usually 44 or 55 and never more than 1111. Each solution involves approximately 2n22n2 operations.
In practice the condition number estimator is very reliable, but it can underestimate the true condition number; see Section 15.3 of Higham (2002) for further details.
The complex analogue of this function is nag_lapack_zgesvx (f07ap).

Example

function nag_lapack_dgesvx_example
fact = 'Equilibration';
trans = 'No transpose';
a = [1.8, 2.88, 2.05, -0.89;
     525, -295, -95, -380;
     1.58, -2.69, -2.9, -1.04;
     -1.11, -0.66, -0.59, 0.8];
af = zeros(4, 4);
ipiv = [int64(10581220);8183732;20;-1081507120];
equed = ' ';
r = zeros(4, 1);
c = zeros(4, 1);
b = [9.52, 18.47;
     2435, 225;
     0.77, -13.28;
     -6.22, -6.21];
[aOut, afOut, ipivOut, equedOut, rOut, cOut, bOut, x, rcond, ferr, berr, work, info] = ...
    nag_lapack_dgesvx(fact, trans, a, af, ipiv, equed, r, c, b)
 

aOut =

    0.6250    1.0000    0.7118   -0.3090
    1.0000   -0.5619   -0.1810   -0.7238
    0.5448   -0.9276   -1.0000   -0.3586
   -1.0000   -0.5946   -0.5315    0.7207


afOut =

    1.0000   -0.5619   -0.1810   -0.7238
    0.6250    1.3512    0.8249    0.1434
    0.5448   -0.4599   -0.5220    0.1017
   -1.0000   -0.8559    0.0123    0.1184


ipivOut =

                    2
                    2
                    3
                    4


equedOut =

R


rOut =

    0.3472
    0.0019
    0.3448
    0.9009


cOut =

    1.0000
    1.0000
    1.0000
    1.3816


bOut =

    3.3056    6.4132
    4.6381    0.4286
    0.2655   -4.5793
   -5.6036   -5.5946


x =

    1.0000    3.0000
   -1.0000    2.0000
    3.0000    4.0000
   -5.0000    1.0000


rcond =

    0.0182


ferr =

   1.0e-13 *

    0.2384
    0.3301


berr =

   1.0e-16 *

    0.6800
    0.8040


work =

    0.7401
    0.0000
    0.0000
    0.0000
   -0.0000
    0.0000
   -0.0000
   -0.0000
    0.0000
    0.0000
   -0.0000
    0.0000
         0
    0.5619
    1.0059
    0.9688


info =

                    0


function f07ab_example
fact = 'Equilibration';
trans = 'No transpose';
a = [1.8, 2.88, 2.05, -0.89;
     525, -295, -95, -380;
     1.58, -2.69, -2.9, -1.04;
     -1.11, -0.66, -0.59, 0.8];
af = zeros(4, 4);
ipiv = [int64(10581220);8183732;20;-1081507120];
equed = ' ';
r = zeros(4, 1);
c = zeros(4, 1);
b = [9.52, 18.47;
     2435, 225;
     0.77, -13.28;
     -6.22, -6.21];
[aOut, afOut, ipivOut, equedOut, rOut, cOut, bOut, x, rcond, ferr, berr, work, info] = ...
    f07ab(fact, trans, a, af, ipiv, equed, r, c, b)
 

aOut =

    0.6250    1.0000    0.7118   -0.3090
    1.0000   -0.5619   -0.1810   -0.7238
    0.5448   -0.9276   -1.0000   -0.3586
   -1.0000   -0.5946   -0.5315    0.7207


afOut =

    1.0000   -0.5619   -0.1810   -0.7238
    0.6250    1.3512    0.8249    0.1434
    0.5448   -0.4599   -0.5220    0.1017
   -1.0000   -0.8559    0.0123    0.1184


ipivOut =

                    2
                    2
                    3
                    4


equedOut =

R


rOut =

    0.3472
    0.0019
    0.3448
    0.9009


cOut =

    1.0000
    1.0000
    1.0000
    1.3816


bOut =

    3.3056    6.4132
    4.6381    0.4286
    0.2655   -4.5793
   -5.6036   -5.5946


x =

    1.0000    3.0000
   -1.0000    2.0000
    3.0000    4.0000
   -5.0000    1.0000


rcond =

    0.0182


ferr =

   1.0e-13 *

    0.2384
    0.3301


berr =

   1.0e-16 *

    0.6800
    0.8040


work =

    0.7401
    0.0000
    0.0000
    0.0000
   -0.0000
    0.0000
   -0.0000
   -0.0000
    0.0000
    0.0000
   -0.0000
    0.0000
         0
    0.5619
    1.0059
    0.9688


info =

                    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