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_linsys_real_square_solve_1rhs (f04at)

Purpose

nag_linsys_real_square_solve_1rhs (f04at) calculates the accurate solution of a set of real linear equations with a single right-hand side, using an LULU factorization with partial pivoting, and iterative refinement.

Syntax

[c, aa, ifail] = f04at(a, b, 'n', n)
[c, aa, ifail] = nag_linsys_real_square_solve_1rhs(a, b, 'n', n)

Description

Given a set of real linear equations, Ax = bAx=b, the function first computes an LULU factorization of AA with partial pivoting, PA = LUPA=LU, where PP is a permutation matrix, LL is lower triangular and UU is unit upper triangular. An approximation to xx is found by forward and backward substitution in Ly = PbLy=Pb and Ux = yUx=y. The residual vector r = bAxr=b-Ax is then calculated using additional precision, and a correction dd to xx is found by solving LUd = rLUd=r. xx is replaced by x + dx+d, and this iterative refinement of the solution is repeated until full machine accuracy is obtained.

References

Wilkinson J H and Reinsch C (1971) Handbook for Automatic Computation II, Linear Algebra Springer–Verlag

Parameters

Compulsory Input Parameters

1:     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.
2:     b( : :) – double array
Note: the dimension of the array b must be at least max (1,n)max(1,n).
The right-hand side vector bb.

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The first dimension of the array a The second dimension of the arrays a, b.
nn, the order of the matrix AA.
Constraint: n0n0.

Input Parameters Omitted from the MATLAB Interface

lda ldaa wks1 wks2

Output Parameters

1:     c(n) – double array
The solution vector xx.
2:     aa(ldaa,nn) – double array
The first dimension of the array aa will be max (1,n)max(1,n)
The second dimension of the array will be max (1,n)max(1,n)
ldaamax (1,n)ldaamax(1,n).
The triangular factors LL and UU, except that the unit diagonal elements of UU are not stored.
3:     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
The matrix AA is singular, possibly due to rounding errors.
  ifail = 2ifail=2
Iterative refinement fails to improve the solution, i.e., the matrix AA is too ill-conditioned.
  ifail = 3ifail=3
On entry,n < 0n<0,
orlda < max (1,n)lda<max(1,n),
orldaa < max (1,n)ldaa<max(1,n).

Accuracy

The computed solutions should be correct to full machine accuracy. For a detailed error analysis see page 107 of Wilkinson and Reinsch (1971).

Further Comments

The time taken by nag_linsys_real_square_solve_1rhs (f04at) is approximately proportional to n3n3.
The function must not be called with the same name for parameters b and c.

Example

function nag_linsys_real_square_solve_1rhs_example
a = [33, 16, 72;
     -24, -10, -57;
     -8, -4, -17];
b = [-359;
     281;
     85];
[c, aa, ifail] = nag_linsys_real_square_solve_1rhs(a, b)
 

c =

     1
    -2
    -5


aa =

   -8.0000    0.5000    2.1250
  -24.0000    2.0000   -3.0000
   33.0000   -0.5000    0.3750


ifail =

                    0


function f04at_example
a = [33, 16, 72;
     -24, -10, -57;
     -8, -4, -17];
b = [-359;
     281;
     85];
[c, aa, ifail] = f04at(a, b)
 

c =

     1
    -2
    -5


aa =

   -8.0000    0.5000    2.1250
  -24.0000    2.0000   -3.0000
   33.0000   -0.5000    0.3750


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