NAG CL Interface
f07bbc (dgbsvx)

Settings help

CL Name Style:


1 Purpose

f07bbc uses the LU factorization to compute the solution to a real system of linear equations
AX=B   or   ATX=B ,  
where A is an n×n band matrix with kl subdiagonals and ku superdiagonals, and X and B are n×r matrices. Error bounds on the solution and a condition estimate are also provided.

2 Specification

#include <nag.h>
void  f07bbc (Nag_OrderType order, Nag_FactoredFormType fact, Nag_TransType trans, Integer n, Integer kl, Integer ku, Integer nrhs, double ab[], Integer pdab, double afb[], Integer pdafb, Integer ipiv[], Nag_EquilibrationType *equed, double r[], double c[], double b[], Integer pdb, double x[], Integer pdx, double *rcond, double ferr[], double berr[], double *recip_growth_factor, NagError *fail)
The function may be called by the names: f07bbc, nag_lapacklin_dgbsvx or nag_dgbsvx.

3 Description

f07bbc performs the following steps:
  1. 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=Nag_EquilibrateAndFactor. 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 and ATX=B are
    (DRADC) (DC-1X) = DR B  
    and
    (DRADC) T (DR-1X) = DC B ,  
    respectively, where DR and DC are diagonal matrices, with positive diagonal elements, formed from the computed scaling factors.
    When equilibration is used, A will be overwritten by DR A DC and B will be overwritten by DR B (or DC B when the solution of ATX=B is sought).
  2. 2.Factorization
    The matrix A, or its scaled form, is copied and factored using the LU decomposition
    A=PLU ,  
    where P is a permutation matrix, L is a unit lower triangular matrix, and U 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 f07bbc with the same matrix A.
  3. 3.Condition Number Estimation
    The LU factorization of A determines whether a solution to the linear system exists. If some diagonal element of U is zero, then U is exactly singular, no solution exists and the function returns with a failure. Otherwise the factorized form of A is used to estimate the condition number of the matrix A. If the reciprocal of the condition number is less than machine precision then a warning code is returned on final exit.
  4. 4.Solution
    The (equilibrated) system is solved for X ( DC-1X or DR-1X ) using the factored form of A ( DRADC ).
  5. 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. 6.Construct Solution Matrix X
    If equilibration was used, the matrix X is premultiplied by DC (if trans=Nag_NoTrans) or DR (if trans=Nag_Trans or Nag_ConjTrans) so that it solves the original system before equilibration.

4 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 https://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

5 Arguments

1: order Nag_OrderType Input
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by order=Nag_RowMajor. See Section 3.1.3 in the Introduction to the NAG Library CL Interface for a more detailed explanation of the use of this argument.
Constraint: order=Nag_RowMajor or Nag_ColMajor.
2: fact Nag_FactoredFormType Input
On entry: specifies whether or not the factorized form of the matrix A is supplied on entry, and if not, whether the matrix A should be equilibrated before it is factorized.
fact=Nag_Factored
afb and ipiv contain the factorized form of A. If equedNag_NoEquilibration, the matrix A has been equilibrated with scaling factors given by r and c. ab, afb and ipiv are not modified.
fact=Nag_NotFactored
The matrix A will be copied to afb and factorized.
fact=Nag_EquilibrateAndFactor
The matrix A will be equilibrated if necessary, then copied to afb and factorized.
Constraint: fact=Nag_Factored, Nag_NotFactored or Nag_EquilibrateAndFactor.
3: trans Nag_TransType Input
On entry: specifies the form of the system of equations.
trans=Nag_NoTrans
AX=B (No transpose).
trans=Nag_Trans or Nag_ConjTrans
ATX=B (Transpose).
Constraint: trans=Nag_NoTrans, Nag_Trans or Nag_ConjTrans.
4: n Integer Input
On entry: n, the number of linear equations, i.e., the order of the matrix A.
Constraint: n0.
5: kl Integer Input
On entry: kl, the number of subdiagonals within the band of the matrix A.
Constraint: kl0.
6: ku Integer Input
On entry: ku, the number of superdiagonals within the band of the matrix A.
Constraint: ku0.
7: nrhs Integer Input
On entry: r, the number of right-hand sides, i.e., the number of columns of the matrix B.
Constraint: nrhs0.
8: ab[dim] double Input/Output
Note: the dimension, dim, of the array ab must be at least max(1,pdab×n).
On entry: the n×n coefficient matrix A.
This is stored as a notional two-dimensional array with row elements or column elements stored contiguously. The storage of elements Aij, for row i=1,,n and column j=max(1,i-kl),,min(n,i+ku), depends on the order argument as follows:
  • if order=Nag_ColMajor, Aij is stored as ab[(j-1)×pdab+ku+i-j];
  • if order=Nag_RowMajor, Aij is stored as ab[(i-1)×pdab+kl+j-i].
See Section 9 for further details.
If fact=Nag_Factored and equedNag_NoEquilibration, A must have been equilibrated by the scaling factors in r and/or c.
On exit: if fact=Nag_Factored or Nag_NotFactored, or if fact=Nag_EquilibrateAndFactor and equed=Nag_NoEquilibration, ab is not modified.
If equedNag_NoEquilibration then, if no constraints are violated, A is scaled as follows:
  • if equed=Nag_RowEquilibration, A=DrA;
  • if equed=Nag_ColumnEquilibration, A=ADc;
  • if equed=Nag_RowAndColumnEquilibration, A=DrADc.
9: pdab Integer Input
On entry: the stride separating row or column elements (depending on the value of order) of the matrix A in the array ab.
Constraint: pdabkl+ku+1.
10: afb[dim] double Input/Output
Note: the dimension, dim, of the array afb must be at least max(1,pdafb×n).
On entry: if fact=Nag_NotFactored or Nag_EquilibrateAndFactor, afb need not be set.
If fact=Nag_Factored, details of the LU factorization of the n×n band matrix A, as computed by f07bdc.
The elements, uij, of the upper triangular band factor U with kl+ku super-diagonals, and the multipliers, lij, used to form the lower triangular factor L are stored. The elements uij, for i=1,,n and j=i,,min(n,i+kl+ku), and lij, for i=1,,n and j=max(1,i-kl),,i, are stored where Aij is stored on entry.
If equedNag_NoEquilibration, afb is the factorized form of the equilibrated matrix A.
On exit: if fact=Nag_Factored, afb is unchanged from entry.
Otherwise, if no constraints are violated, then if fact=Nag_NotFactored, afb returns details of the LU factorization of the band matrix A, and if fact=Nag_EquilibrateAndFactor, afb returns details of the LU factorization of the equilibrated band matrix A (see the description of ab for the form of the equilibrated matrix).
11: pdafb Integer Input
On entry: the stride separating row or column elements (depending on the value of order) of the matrix A in the array afb.
Constraint: pdafb2×kl+ku+1.
12: ipiv[dim] Integer Input/Output
Note: the dimension, dim, of the array ipiv must be at least max(1,n).
On entry: if fact=Nag_NotFactored or Nag_EquilibrateAndFactor, ipiv need not be set.
If fact=Nag_Factored, ipiv contains the pivot indices from the factorization A=LU, as computed by f07bdc; row i of the matrix was interchanged with row ipiv[i-1].
On exit: if fact=Nag_Factored, ipiv is unchanged from entry.
Otherwise, if no constraints are violated, ipiv contains the pivot indices that define the permutation matrix P; at the ith step row i of the matrix was interchanged with row ipiv[i-1]. ipiv[i-1]=i indicates a row interchange was not required.
If fact=Nag_NotFactored, the pivot indices are those corresponding to the factorization A=LU of the original matrix A.
If fact=Nag_EquilibrateAndFactor, the pivot indices are those corresponding to the factorization of A=LU of the equilibrated matrix A.
13: equed Nag_EquilibrationType * Input/Output
On entry: if fact=Nag_NotFactored or Nag_EquilibrateAndFactor, equed need not be set.
If fact=Nag_Factored, equed must specify the form of the equilibration that was performed as follows:
  • if equed=Nag_NoEquilibration, no equilibration;
  • if equed=Nag_RowEquilibration, row equilibration, i.e., A has been premultiplied by DR;
  • if equed=Nag_ColumnEquilibration, column equilibration, i.e., A has been postmultiplied by DC;
  • if equed=Nag_RowAndColumnEquilibration, both row and column equilibration, i.e., A has been replaced by DRADC.
On exit: if fact=Nag_Factored, equed is unchanged from entry.
Otherwise, if no constraints are violated, equed specifies the form of equilibration that was performed as specified above.
Constraint: if fact=Nag_Factored, equed=Nag_NoEquilibration, Nag_RowEquilibration, Nag_ColumnEquilibration or Nag_RowAndColumnEquilibration.
14: r[dim] double Input/Output
Note: the dimension, dim, of the array r must be at least max(1,n).
On entry: if fact=Nag_NotFactored or Nag_EquilibrateAndFactor, r need not be set.
If fact=Nag_Factored and equed=Nag_RowEquilibration or Nag_RowAndColumnEquilibration, r must contain the row scale factors for A, DR; each element of r must be positive.
On exit: if fact=Nag_Factored, r is unchanged from entry.
Otherwise, if no constraints are violated and equed=Nag_RowEquilibration or Nag_RowAndColumnEquilibration, r contains the row scale factors for A, DR, such that A is multiplied on the left by DR; each element of r is positive.
15: c[dim] double Input/Output
Note: the dimension, dim, of the array c must be at least max(1,n).
On entry: if fact=Nag_NotFactored or Nag_EquilibrateAndFactor, c need not be set.
If fact=Nag_Factored and equed=Nag_ColumnEquilibration or Nag_RowAndColumnEquilibration, c must contain the column scale factors for A, DC; each element of c must be positive.
On exit: if fact=Nag_Factored, c is unchanged from entry.
Otherwise, if no constraints are violated and equed=Nag_ColumnEquilibration or Nag_RowAndColumnEquilibration, c contains the row scale factors for A, DC; each element of c is positive.
16: b[dim] double Input/Output
Note: the dimension, dim, of the array b must be at least
  • max(1,pdb×nrhs) when order=Nag_ColMajor;
  • max(1,n×pdb) when order=Nag_RowMajor.
The (i,j)th element of the matrix B is stored in
  • b[(j-1)×pdb+i-1] when order=Nag_ColMajor;
  • b[(i-1)×pdb+j-1] when order=Nag_RowMajor.
On entry: the n×r right-hand side matrix B.
On exit: if equed=Nag_NoEquilibration, b is not modified.
If trans=Nag_NoTrans and equed=Nag_RowEquilibration or Nag_RowAndColumnEquilibration, b is overwritten by DRB.
If trans=Nag_Trans or Nag_ConjTrans and equed=Nag_ColumnEquilibration or Nag_RowAndColumnEquilibration, b is overwritten by DCB.
17: pdb Integer Input
On entry: the stride separating row or column elements (depending on the value of order) in the array b.
Constraints:
  • if order=Nag_ColMajor, pdbmax(1,n);
  • if order=Nag_RowMajor, pdbmax(1,nrhs).
18: x[dim] double Output
Note: the dimension, dim, of the array x must be at least
  • max(1,pdx×nrhs) when order=Nag_ColMajor;
  • max(1,n×pdx) when order=Nag_RowMajor.
The (i,j)th element of the matrix X is stored in
  • x[(j-1)×pdx+i-1] when order=Nag_ColMajor;
  • x[(i-1)×pdx+j-1] when order=Nag_RowMajor.
On exit: if fail.code= NE_NOERROR or NE_SINGULAR_WP, the n×r solution matrix X to the original system of equations. Note that the arrays A and B are modified on exit if equedNag_NoEquilibration, and the solution to the equilibrated system is DC-1X if trans=Nag_NoTrans and equed=Nag_ColumnEquilibration or Nag_RowAndColumnEquilibration, or DR-1X if trans=Nag_Trans or Nag_ConjTrans and equed=Nag_RowEquilibration or Nag_RowAndColumnEquilibration.
19: pdx Integer Input
On entry: the stride separating row or column elements (depending on the value of order) in the array x.
Constraints:
  • if order=Nag_ColMajor, pdxmax(1,n);
  • if order=Nag_RowMajor, pdxmax(1,nrhs).
20: rcond double * Output
On exit: if no constraints are violated, an estimate of the reciprocal condition number of the matrix A (after equilibration if that is performed), computed as rcond=1.0/(A1A-11).
21: ferr[nrhs] double Output
On exit: if fail.code= NE_NOERROR or NE_SINGULAR_WP, an estimate of the forward error bound for each computed solution vector, such that x^j-xj/xjferr[j-1] where x^j is the jth column of the computed solution returned in the array x and xj is the corresponding column of the exact solution X. The estimate is as reliable as the estimate for rcond, and is almost always a slight overestimate of the true error.
22: berr[nrhs] double Output
On exit: if fail.code= NE_NOERROR or NE_SINGULAR_WP, an estimate of the component-wise relative backward error of each computed solution vector x^j (i.e., the smallest relative change in any element of A or B that makes x^j an exact solution).
23: recip_growth_factor double * Output
On exit: if fail.code= NE_NOERROR, the reciprocal pivot growth factor A/U, where . denotes the maximum absolute element norm. If recip_growth_factor1, the stability of the LU factorization of (equilibrated) A 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 fail.code= NE_SINGULAR, then recip_growth_factor contains the reciprocal pivot growth factor for the leading fail.errnum columns of A.
24: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_INT
On entry, kl=value.
Constraint: kl0.
On entry, ku=value.
Constraint: ku0.
On entry, n=value.
Constraint: n0.
On entry, nrhs=value.
Constraint: nrhs0.
On entry, pdab=value.
Constraint: pdab>0.
On entry, pdafb=value.
Constraint: pdafb>0.
On entry, pdb=value.
Constraint: pdb>0.
On entry, pdx=value.
Constraint: pdx>0.
NE_INT_2
On entry, pdb=value and n=value.
Constraint: pdbmax(1,n).
On entry, pdb=value and nrhs=value.
Constraint: pdbmax(1,nrhs).
On entry, pdx=value and n=value.
Constraint: pdxmax(1,n).
On entry, pdx=value and nrhs=value.
Constraint: pdxmax(1,nrhs).
NE_INT_3
On entry, pdab=value, kl=value and ku=value.
Constraint: pdabkl+ku+1.
On entry, pdafb=value, kl=value and ku=value.
Constraint: pdafb2×kl+ku+1.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_SINGULAR
Element value of the diagonal is exactly zero. The factorization has been completed, but the factor U is exactly singular, so the solution and error bounds could not be computed. rcond=0.0 is returned.
NE_SINGULAR_WP
U 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.

7 Accuracy

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

8 Parallelism and Performance

f07bbc is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
f07bbc makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9 Further Comments

The band storage scheme for the array ab is illustrated by the following example, when n=6 , kl=1 , and ku=2 . Storage of the band matrix A in the array ab:
order=Nag_ColMajor * * a13 a24 a35 a46 * a12 a23 a34 a45 a56 a11 a22 a33 a44 a55 a66 a21 a32 a43 a54 a65 * order=Nag_RowMajor * a11 a12 a13 a21 a22 a23 a24 a32 a33 a34 a35 a43 a44 a45 a46 a54 a55 a56 * a65 a66 * *  
The total number of floating-point operations required to solve the equations AX=B depends upon the pivoting required, but if nkl + ku then it is approximately bounded by O( n kl ( kl + ku ) ) for the factorization and O( n (2kl+ku) r ) for the solution following the factorization. The condition number estimation typically requires between four and five solves and never more than eleven solves, following the factorization. The solution is then refined, and the errors estimated, using iterative refinement; see f07bhc for information on the floating-point operations required.
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 f07bpc.

10 Example

This example solves the equations
AX=B ,  
where A is the band matrix
A = ( -0.23 2.54 -3.66 0.00 -6.98 2.46 -2.73 -2.13 0.00 2.56 2.46 4.07 0.00 0.00 -4.78 -3.82 )   and   B = ( 4.42 -36.01 27.13 -31.67 -6.14 -1.16 10.50 -25.82 ) .  
Estimates for the backward errors, forward errors, condition number and pivot growth are also output, together with information on the equilibration of A .

10.1 Program Text

Program Text (f07bbce.c)

10.2 Program Data

Program Data (f07bbce.d)

10.3 Program Results

Program Results (f07bbce.r)