NAG Library Function Document

nag_zgesvx (f07apc)

 Contents

    1  Purpose
    7  Accuracy

1
Purpose

nag_zgesvx (f07apc) uses the LU factorization to compute the solution to a complex system of linear equations
AX=B   or   ATX=B   or   AHX=B ,  
where A is an n by n matrix 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_zgesvx (Nag_OrderType order, Nag_FactoredFormType fact, Nag_TransType trans, Integer n, Integer nrhs, Complex a[], Integer pda, Complex af[], Integer pdaf, 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_zgesvx (f07apc) 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_zgesvx (f07apc) 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 3.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
af 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. a, af and ipiv are not modified.
fact=Nag_NotFactored
The matrix A will be copied to af and factorized.
fact=Nag_EquilibrateAndFactor
The matrix A will be equilibrated if necessary, then copied to af 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:     nrhs IntegerInput
On entry: r, the number of right-hand sides, i.e., the number of columns of the matrix B.
Constraint: nrhs0.
6:     a[dim] ComplexInput/Output
Note: the dimension, dim, of the array a must be at least max1,pda×n.
The i,jth element of the matrix A is stored in
  • a[j-1×pda+i-1] when order=Nag_ColMajor;
  • a[i-1×pda+j-1] when order=Nag_RowMajor.
On entry: the n by n matrix A.
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, a is not modified.
If fact=Nag_EquilibrateAndFactor or equedNag_NoEquilibration, A is scaled as follows:
  • if equed=Nag_RowEquilibration, A=DRA;
  • if equed=Nag_ColumnEquilibration, A=ADC;
  • if equed=Nag_RowAndColumnEquilibration, A=DRADC.
7:     pda IntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array a.
Constraint: pdamax1,n.
8:     af[dim] ComplexInput/Output
Note: the dimension, dim, of the array af must be at least max1,pdaf×n.
The i,jth element of the matrix is stored in
  • af[j-1×pdaf+i-1] when order=Nag_ColMajor;
  • af[i-1×pdaf+j-1] when order=Nag_RowMajor.
On entry: if fact=Nag_Factored, af contains the factors L and U from the factorization A=PLU as computed by nag_zgetrf (f07arc). If equedNag_NoEquilibration, af is the factorized form of the equilibrated matrix A.
If fact=Nag_NotFactored or Nag_EquilibrateAndFactor, af need not be set.
On exit: if fact=Nag_NotFactored, af returns the factors L and U from the factorization A=PLU of the original matrix A.
If fact=Nag_EquilibrateAndFactor, af returns the factors L and U from the factorization A=PLU of the equilibrated matrix A (see the description of a for the form of the equilibrated matrix).
If fact=Nag_Factored, af is unchanged from entry.
9:     pdaf IntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array af.
Constraint: pdafmax1,n.
10:   ipiv[dim] IntegerInput/Output
Note: the dimension, dim, of the array ipiv must be at least max1,n.
On entry: if fact=Nag_Factored, ipiv contains the pivot indices from the factorization A=PLU as computed by nag_zgetrf (f07arc); 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 or Nag_EquilibrateAndFactor, ipiv need not be set.
On exit: if fact=Nag_NotFactored, ipiv contains the pivot indices from the factorization A=PLU of the original matrix A.
If fact=Nag_EquilibrateAndFactor, ipiv contains the pivot indices from the factorization A=PLU of the equilibrated matrix A.
If fact=Nag_Factored, ipiv is unchanged from entry.
11:   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.
12:   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.
13:   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 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.
14:   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.
15:   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.
16:   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.
17:   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.
18:   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 .
19:   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.
20:   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).
21:   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.
22:   fail NagError *Input/Output
The NAG error argument (see Section 3.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, n=value.
Constraint: n0.
On entry, nrhs=value.
Constraint: nrhs0.
On entry, pda=value.
Constraint: pda>0.
On entry, pdaf=value.
Constraint: pdaf>0.
On entry, pdb=value.
Constraint: pdb>0.
On entry, pdx=value.
Constraint: pdx>0.
NE_INT_2
On entry, pda=value and n=value.
Constraint: pdamax1,n.
On entry, pdaf=value and n=value.
Constraint: pdafmax1,n.
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_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 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_zgesvx (f07apc) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
nag_zgesvx (f07apc) 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 factorization of A  requires approximately 83 n3  floating-point operations.
Estimating the forward error involves solving a number of systems of linear equations of the form Ax=b or ATx=b; the number is usually 4 or 5 and never more than 11. Each solution involves approximately 8n2 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 real analogue of this function is nag_dgesvx (f07abc).

10
Example

This example solves the equations
AX=B ,  
where A is the general matrix
A= -1.34+02.55i 0.28+3.17i -6.39-02.20i 0.72-00.92i -1.70-14.10i 33.10-1.50i -1.50+13.40i 12.90+13.80i -3.29-02.39i -1.91+4.42i -0.14-01.35i 1.72+01.35i 2.41+00.39i -0.56+1.47i -0.83-00.69i -1.96+00.67i  
and
B= 26.26+51.78i 31.32-06.70i 64.30-86.80i 158.60-14.20i -5.75+25.31i -2.15+30.19i 1.16+02.57i -2.56+07.55i .  
Error estimates for the solutions, information on scaling, an estimate of the reciprocal of the condition number of the scaled matrix A and an estimate of the reciprocal of the pivot growth factor for the factorization of A are also output.

10.1
Program Text

Program Text (f07apce.c)

10.2
Program Data

Program Data (f07apce.d)

10.3
Program Results

Program Results (f07apce.r)

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