# naginterfaces.library.lapacklin.dgesvx¶

naginterfaces.library.lapacklin.dgesvx(fact, trans, n, nrhs, a, equed, b, af=None, ipiv=None, r=None, c=None)[source]

dgesvx uses the factorization to compute the solution to a real system of linear equations

where is an matrix and and are matrices. Error bounds on the solution and a condition estimate are also provided.

For full information please refer to the NAG Library document for f07ab

https://www.nag.com/numeric/nl/nagdoc_27.3/flhtml/f07/f07abf.html

Parameters
factstr, length 1

Specifies whether or not the factorized form of the matrix is supplied on entry, and if not, whether the matrix should be equilibrated before it is factorized.

and contain the factorized form of . If , the matrix has been equilibrated with scaling factors given by and . , and are not modified.

The matrix will be copied to and factorized.

The matrix will be equilibrated if necessary, then copied to and factorized.

transstr, length 1

Specifies the form of the system of equations.

(No transpose).

or

(Transpose).

nint

, the number of linear equations, i.e., the order of the matrix .

nrhsint

, the number of right-hand sides, i.e., the number of columns of the matrix .

afloat, array-like, shape

The matrix .

If and , must have been equilibrated by the scaling factors in and/or .

equedNone or str, length 1

If or , need not be set.

If , must specify the form of the equilibration that was performed as follows:

if , no equilibration;

if , row equilibration, i.e., has been premultiplied by ;

if , column equilibration, i.e., has been postmultiplied by ;

if , both row and column equilibration, i.e., has been replaced by .

bfloat, array-like, shape

The right-hand side matrix .

afNone or float, array-like, shape , optional

If , contains the factors and from the factorization as computed by dgetrf(). If , is the factorized form of the equilibrated matrix .

If or , need not be set.

ipivNone or int, array-like, shape , optional

If , contains the pivot indices from the factorization as computed by dgetrf(); at the th step row of the matrix was interchanged with row . indicates a row interchange was not required.

If or , need not be set.

rNone or float, array-like, shape , optional

If or , need not be set.

If and or , must contain the row scale factors for , ; each element of must be positive.

cNone or float, array-like, shape , optional

If or , need not be set.

If and or , must contain the column scale factors for , ; each element of must be positive.

Returns
afloat, ndarray, shape

If or , or if and , is not modified.

If or , is scaled as follows:

if , ;

if , ;

if , .

afNone or float, ndarray, shape

If , returns the factors and from the factorization of the original matrix .

If , returns the factors and from the factorization of the equilibrated matrix (see the description of for the form of the equilibrated matrix).

If , is unchanged from entry.

ipivNone or int, ndarray, shape

If , contains the pivot indices from the factorization of the original matrix .

If , contains the pivot indices from the factorization of the equilibrated matrix .

If , is unchanged from entry.

equedNone or str, length 1

If , is unchanged from entry.

Otherwise, if no constraints are violated, specifies the form of equilibration that was performed as specified above.

rNone or float, ndarray, shape

If , is unchanged from entry.

Otherwise, if no constraints are violated and or , contains the row scale factors for , , such that is multiplied on the left by ; each element of is positive.

cNone or float, ndarray, shape

If , is unchanged from entry.

Otherwise, if no constraints are violated and or , contains the row scale factors for , ; each element of is positive.

bfloat, ndarray, shape

If , is not modified.

If and or , is overwritten by .

If or and or , is overwritten by .

xfloat, ndarray, shape

If the function exits successfully or = + 1, the solution matrix to the original system of equations. Note that the arrays and are modified on exit if , and the solution to the equilibrated system is if and or , or if or and or .

rcondfloat

If no constraints are violated, an estimate of the reciprocal condition number of the matrix (after equilibration if that is performed), computed as .

ferrfloat, ndarray, shape

If the function exits successfully or = + 1, an estimate of the forward error bound for each computed solution vector, such that where is the th column of the computed solution returned in the array and is the corresponding column of the exact solution . The estimate is as reliable as the estimate for , and is almost always a slight overestimate of the true error.

berrfloat, ndarray, shape

If the function exits successfully or = + 1, an estimate of the component-wise relative backward error of each computed solution vector (i.e., the smallest relative change in any element of or that makes an exact solution).

recip_growth_factorfloat

If no exception or warning is raised, the reciprocal pivot growth factor , where denotes the maximum absolute element norm. If , the stability of the factorization of (equilibrated) could be poor. This also means that the solution , condition estimate , and forward error bound could be unreliable. If the factorization fails with in 1 … , then contains the reciprocal pivot growth factor for the leading columns of .

Raises
NagValueError
(errno )

On entry, error in parameter .

Constraint: , or .

(errno )

On entry, error in parameter .

Constraint: , or .

(errno )

On entry, error in parameter .

Constraint: .

(errno )

On entry, error in parameter .

Constraint: .

(errno )

On entry, error in parameter .

Constraint: , , or .

(errno )

On entry, error in parameter .

(errno )

On entry, error in parameter .

Warns
NagAlgorithmicWarning
(errno )

Element of the diagonal is exactly zero. The factorization has been completed, but the factor is exactly singular, so the solution and error bounds could not be computed. is returned.

(errno )

is nonsingular, but 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 would suggest.

Notes

dgesvx 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 . 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 and are

and

respectively, where and are diagonal matrices, with positive diagonal elements, formed from the computed scaling factors.

When equilibration is used, will be overwritten by and will be overwritten by (or when the solution of is sought).

2. Factorization

The matrix , or its scaled form, is copied and factored using the decomposition

where is a permutation matrix, is a unit lower triangular matrix, and 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 dgesvx with the same matrix .

3. Condition Number Estimation

The factorization of determines whether a solution to the linear system exists. If some diagonal element of is zero, then is exactly singular, no solution exists and the function returns with a failure. Otherwise the factorized form of is used to estimate the condition number of the matrix . 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 ( or ) using the factored form of ().

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

If equilibration was used, the matrix is premultiplied by (if ) or (if or ) so that it solves the original system before equilibration.

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