PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_linsys_real_tridiag_fac_solve (f04le)
Purpose
nag_linsys_real_tridiag_fac_solve (f04le) solves a system of tridiagonal equations following the factorization by
nag_matop_real_gen_tridiag_lu (f01le). This function is intended for applications such as inverse iteration as well as straightforward linear equation applications.
Syntax
[
y,
tol,
ifail] = f04le(
job,
a,
b,
c,
d,
ipiv,
y,
tol, 'n',
n)
[
y,
tol,
ifail] = nag_linsys_real_tridiag_fac_solve(
job,
a,
b,
c,
d,
ipiv,
y,
tol, 'n',
n)
Description
Following the factorization of the
by
tridiagonal matrix
as
by
nag_matop_real_gen_tridiag_lu (f01le),
nag_linsys_real_tridiag_fac_solve (f04le) may be used to solve any of the equations
for
, the choice of equation being controlled by the argument
job. In each case there is an option to perturb zero or very small diagonal elements of
, this option being intended for use in applications such as inverse iteration.
References
Wilkinson J H (1965) The Algebraic Eigenvalue Problem Oxford University Press, Oxford
Wilkinson J H and Reinsch C (1971) Handbook for Automatic Computation II, Linear Algebra Springer–Verlag
Parameters
Compulsory Input Parameters
- 1:
– int64int32nag_int scalar
-
Must specify the equations to be solved.
- The equations are to be solved, but diagonal elements of are not to be perturbed.
- The equations are to be solved and, if overflow would otherwise occur, diagonal elements of are to be perturbed. See argument tol.
- The equations are to be solved, but diagonal elements of are not to be perturbed.
- The equations are to be solved and, if overflow would otherwise occur, diagonal elements of are to be perturbed. See argument tol.
- The equations are to be solved, but diagonal elements of are not to be perturbed.
- The equations are to be solved and, if overflow would otherwise occur, diagonal elements of are to be perturbed. See argument tol.
- 2:
– double array
-
The diagonal elements of as returned by nag_linsys_real_tridiag_fac_solve (f04le).
- 3:
– double array
-
The elements of the first superdiagonal of as returned by nag_linsys_real_tridiag_fac_solve (f04le).
- 4:
– double array
-
The subdiagonal elements of as returned by nag_linsys_real_tridiag_fac_solve (f04le).
- 5:
– double array
-
The elements of the second superdiagonal of as returned by nag_linsys_real_tridiag_fac_solve (f04le).
- 6:
– int64int32nag_int array
-
Details of the matrix
as returned by
nag_matop_real_gen_tridiag_lu (f01le).
- 7:
– double array
-
The right-hand side vector .
- 8:
– double scalar
-
The minimum perturbation to be made to very small diagonal elements of
.
tol is only referenced when
job is negative.
tol should normally be chosen as about
, where
is the
machine precision, but if
tol is supplied as non-positive, then it is reset to
.
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the arrays
a,
b,
c,
d,
ipiv,
y. (An error is raised if these dimensions are not equal.)
, the order of the matrix .
Constraint:
.
Output Parameters
- 1:
– double array
-
y stores the solution vector
.
- 2:
– double scalar
-
If on entry
tol is non-positive, it is reset as just described. Otherwise
tol is unchanged.
- 3:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
On entry, | , |
or | , |
or | or . |
-
-
Overflow would occur when computing the (
)th element of the solution vector
. This can only occur when
job is supplied as positive and either means that a diagonal element of
is very small or that elements of the right-hand side vector
are very large.
-
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.
Accuracy
The computed solution of the equations
, say
, will satisfy an equation of the form
where
can be expected to satisfy a bound of the form
being a modest constant and
being the
machine precision. The computed solution of the equations
and
will satisfy similar results. The above result implies that the relative error in
satisfies
where
is the condition number of
with respect to inversion. Thus if
is nearly singular,
can be expected to have a large relative error. Note that
nag_matop_real_gen_tridiag_lu (f01le) incorporates a test for near singularity.
Further Comments
The time taken by nag_linsys_real_tridiag_fac_solve (f04le) is approximately proportional to .
If you have single systems of tridiagonal equations to solve you are advised that
nag_lapack_dgtsv (f07ca) requires less storage and will normally be faster than the combination of
nag_matop_real_gen_tridiag_lu (f01le) and
nag_linsys_real_tridiag_fac_solve (f04le), but
nag_lapack_dgtsv (f07ca) does not incorporate a test for near singularity.
Example
This example solves the two sets of tridiagonal equations
where
The example program first calls
nag_matop_real_gen_tridiag_lu (f01le) to factorize
and then two calls are made to
nag_linsys_real_tridiag_fac_solve (f04le), one to solve
and the second to solve
.
Open in the MATLAB editor:
f04le_example
function f04le_example
fprintf('f04le example results\n\n');
b = [0 2.1 -1 1.9 8];
a = [3 2.3 -5 -0.9 7.1];
c = [0 3.4 3.6 7 -6];
lambda = 0;
tol = 5e-05;
[D, U1, L, U2, ipiv, ifail] = f01le( ...
a, lambda, b, c, tol);
y = [2.7 -0.5 2.6 0.6 2.7 ];
job = int64(1);
[x, ~, ifail] = f04le( ...
job, D, U1, L, U2, ipiv, y, tol);
disp('Solution vector for Tx = y:');
disp(x);
job = int64(2);
[x, ~, ifail] = f04le( ...
job, D, U1, L, U2, ipiv, y, tol);
disp('Solution vector for T''x = y:');
disp(x);
f04le example results
Solution vector for Tx = y:
-4.0000 7.0000 3.0000 -4.0000 -3.0000
Solution vector for T'x = y:
-4.6304 4.8798 -0.5554 0.6718 -0.3767
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015