nag_zgbsvx (f07bpc) (PDF version)
f07 Chapter Contents
f07 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_zgbsvx (f07bpc)

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

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

2  Specification

#include <nag.h>
#include <nagf07.h>
void  nag_zgbsvx (Nag_OrderType order, Nag_FactoredFormType fact, Nag_TransType trans, Integer n, Integer kl, Integer ku, Integer nrhs, Complex ab[], Integer pdab, Complex afb[], Integer pdafb, Integer ipiv[], Nag_EquilibrationType *equed, double r[], double c[], Complex b[], Integer pdb, Complex x[], Integer pdx, double *rcond, double ferr[], double berr[], double *recip_growth_factor, NagError *fail)

3  Description

nag_zgbsvx (f07bpc) 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=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 , ATX=B  and AHX=B  are
DR A DC DC-1X = DR B ,  
DR A DC T DR-1 X = DC B ,  
and
DR A DC H DR-1 X = 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  or AHX=B  is sought).
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 nag_zgbsvx (f07bpc) with the same matrix A.
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. Solution
The (equilibrated) system is solved for X ( DC-1X  or DR-1X ) using the factored form of A ( 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 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 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

5  Arguments

1:     order Nag_OrderTypeInput
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 2.3.1.3 in How to Use the NAG Library and its Documentation for a more detailed explanation of the use of this argument.
Constraint: order=Nag_RowMajor or Nag_ColMajor.
2:     fact Nag_FactoredFormTypeInput
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_TransTypeInput
On entry: specifies the form of the system of equations.
trans=Nag_NoTrans
AX=B (No transpose).
trans=Nag_Trans
ATX=B (Transpose).
trans=Nag_ConjTrans
AHX=B (Conjugate transpose).
Constraint: trans=Nag_NoTrans, Nag_Trans or Nag_ConjTrans.
4:     n IntegerInput
On entry: n, the number of linear equations, i.e., the order of the matrix A.
Constraint: n0.
5:     kl IntegerInput
On entry: kl, the number of subdiagonals within the band of the matrix A.
Constraint: kl0.
6:     ku IntegerInput
On entry: ku, the number of superdiagonals within the band of the matrix A.
Constraint: ku0.
7:     nrhs IntegerInput
On entry: r, the number of right-hand sides, i.e., the number of columns of the matrix B.
Constraint: nrhs0.
8:     ab[dim] ComplexInput/Output
Note: the dimension, dim, of the array ab must be at least max1,pdab×n.
On entry: the n by 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=max1,i-kl,,minn,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 IntegerInput
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] ComplexInput/Output
Note: the dimension, dim, of the array afb must be at least max1,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 by n band matrix A, as computed by nag_zgbtrf (f07brc).
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,,minn,i+kl+ku, and lij, for i=1,,n and j=max1,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 IntegerInput
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] IntegerInput/Output
Note: the dimension, dim, of the array ipiv must be at least max1,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 nag_dgbtrf (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] doubleInput/Output
Note: the dimension, dim, of the array r must be at least max1,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] doubleInput/Output
Note: the dimension, dim, of the array c must be at least max1,n.
On entry: if fact=Nag_NotFactored or Nag_EquilibrateAndFactor, c need not be set.
If fact=Nag_Factored or 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] ComplexInput/Output
Note: the dimension, dim, of the array b must be at least
  • max1,pdb×nrhs when order=Nag_ColMajor;
  • max1,n×pdb when order=Nag_RowMajor.
The i,jth 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 by 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 IntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array b.
Constraints:
  • if order=Nag_ColMajor, pdbmax1,n;
  • if order=Nag_RowMajor, pdbmax1,nrhs.
18:   x[dim] ComplexOutput
Note: the dimension, dim, of the array x must be at least
  • max1,pdx×nrhs when order=Nag_ColMajor;
  • max1,n×pdx when order=Nag_RowMajor.
The i,jth 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 by 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 IntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array x.
Constraints:
  • if order=Nag_ColMajor, pdxmax1,n;
  • if order=Nag_RowMajor, pdxmax1,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/A1 A-11 .
21:   ferr[nrhs] doubleOutput
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] doubleOutput
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 2.7 in How to Use the NAG Library and its Documentation).

6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation 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: pdbmax1,n.
On entry, pdb=value and nrhs=value.
Constraint: pdbmax1,nrhs.
On entry, pdx=value and n=value.
Constraint: pdxmax1,n.
On entry, pdx=value and nrhs=value.
Constraint: pdxmax1,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.
An unexpected error has been triggered by this function. Please contact NAG.
See Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation 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+Ex^=b, where
EcnεPLU ,  
cn 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 condA,x^,b  
where condA,x^,b = A-1 A x^ + b / x^ condA = 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

nag_zgbsvx (f07bpc) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
nag_zgbsvx (f07bpc) 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 2 kl + 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 nag_zgbrfs (f07bvc) 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 real analogue of this function is nag_dgbsvx (f07bbc).

10  Example

This example solves the equations
AX=B ,  
where A  is the band matrix
A = -1.65+2.26i -2.05-0.85i 0.97-2.84i 0.00i+0.00 6.30i -1.48-1.75i -3.99+4.01i 0.59-0.48i 0.00i+0.00 -0.77+2.83i -1.06+1.94i 3.33-1.04i 0.00i+0.00 0.00i+0.00 4.48-1.09i -0.46-1.72i  
and
B = -1.06+21.50i 12.85+02.84i -22.72-53.90i -70.22+21.57i 28.24-38.60i -20.73-01.23i -34.56+16.73i 26.01+31.97i .  
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 (f07bpce.c)

10.2  Program Data

Program Data (f07bpce.d)

10.3  Program Results

Program Results (f07bpce.r)


nag_zgbsvx (f07bpc) (PDF version)
f07 Chapter Contents
f07 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2016