# library.lapacklin Submodule¶

## Module Summary¶

Interfaces for the NAG Mark 27.0 lapacklin Chapter.

lapacklin - Linear Equations (LAPACK)

This module provides functions for the solution of systems of simultaneous linear equations, and associated computations. It provides functions for

matrix factorizations;

solution of linear equations;

estimating matrix condition numbers;

computing error bounds for the solution of linear equations;

matrix inversion;

computing scaling factors to equilibrate a matrix.

Functions are provided for both real and complex data.

For a general introduction to the solution of systems of linear equations, you should turn first to the F04 Introduction. The decision trees, in the F04 Introduction, direct you to the most appropriate functions in submodule linsys or submodule lapacklin for solving your particular problem. In particular, submodule linsys and submodule lapacklin contain Black Box (or driver) functions which enable some standard types of problem to be solved by a call to a single function. Where possible, functions in submodule linsys call submodule lapacklin functions to perform the necessary computational tasks.

There are two types of driver functions in this module: simple drivers which just return the solution to the linear equations; and expert drivers which also return condition and error estimates and, in many cases, also allow equilibration. The simple drivers for real matrices have names of the form and for complex matrices have names of the form The expert drivers for real matrices have names of the form and for complex matrices have names of the form

The functions in this module (submodule lapacklin) handle only dense and band matrices (not matrices with more specialised structures, or general sparse matrices).

The functions in this module have all been derived from the LAPACK project (see Anderson et al. (1999)). They have been designed to be efficient on a wide range of high-performance computers, without compromising efficiency on conventional serial machines.

naginterfaces.library.examples.lapacklin :
This subpackage contains examples for the lapacklin module. See also the Examples subsection.

## Functionality Index¶

Apply iterative refinement to the solution and compute error estimates

after factorizing the matrix of coefficients

complex band matrix: zgbrfs()

complex Hermitian indefinite matrix: zherfs()

complex Hermitian indefinite matrix, packed storage: zhprfs()

complex Hermitian positive definite band matrix: zpbrfs()

complex Hermitian positive definite matrix: zporfs()

complex Hermitian positive definite matrix, packed storage: zpprfs()

complex Hermitian positive definite tridiagonal matrix: zptrfs()

complex matrix: zgerfs()

complex symmetric indefinite matrix: zsyrfs()

complex symmetric indefinite matrix, packed storage: zsprfs()

complex tridiagonal matrix: zgtrfs()

real band matrix: dgbrfs()

real matrix: dgerfs()

real symmetric indefinite matrix: dsyrfs()

real symmetric indefinite matrix, packed storage: dsprfs()

real symmetric positive definite band matrix: dpbrfs()

real symmetric positive definite matrix: dporfs()

real symmetric positive definite matrix, packed storage: dpprfs()

real symmetric positive definite tridiagonal matrix: dptrfs()

real tridiagonal matrix: dgtrfs()

Compute error estimates

complex triangular band matrix: ztbrfs()

complex triangular matrix: ztrrfs()

complex triangular matrix, packed storage: ztprfs()

real triangular band matrix: dtbrfs()

real triangular matrix: dtrrfs()

real triangular matrix, packed storage: dtprfs()

Compute row and column scalings

complex band matrix: zgbequ()

complex Hermitian positive definite band matrix: zpbequ()

complex Hermitian positive definite matrix: zpoequ()

complex Hermitian positive definite matrix, packed storage: zppequ()

complex matrix: zgeequ()

real band matrix: dgbequ()

real matrix: dgeequ()

real symmetric positive definite band matrix: dpbequ()

real symmetric positive definite matrix: dpoequ()

real symmetric positive definite matrix, packed storage: dppequ()

Condition number estimation

after factorizing the matrix of coefficients

complex band matrix: zgbcon()

complex Hermitian indefinite matrix: zhecon()

complex Hermitian indefinite matrix, packed storage: zhpcon()

complex Hermitian positive definite band matrix: zpbcon()

complex Hermitian positive definite matrix: zpocon()

complex Hermitian positive definite matrix, packed storage: zppcon()

complex Hermitian positive definite tridiagonal matrix: zptcon()

complex matrix: zgecon()

complex symmetric indefinite matrix: zsycon()

complex symmetric indefinite matrix, packed storage: zspcon()

complex tridiagonal matrix: zgtcon()

real band matrix: dgbcon()

real matrix: dgecon()

real symmetric indefinite matrix: dsycon()

real symmetric indefinite matrix, packed storage: dspcon()

real symmetric positive definite band matrix: dpbcon()

real symmetric positive definite matrix: dpocon()

real symmetric positive definite matrix, packed storage: dppcon()

real symmetric positive definite tridiagonal matrix: dptcon()

real tridiagonal matrix: dgtcon()

complex triangular band matrix: ztbcon()

complex triangular matrix: ztrcon()

complex triangular matrix, packed storage: ztpcon()

real triangular band matrix: dtbcon()

real triangular matrix: dtrcon()

real triangular matrix, packed storage: dtpcon()

factorization

complex Hermitian positive definite tridiagonal matrix: zpttrf()

real symmetric positive definite tridiagonal matrix: dpttrf()

or factorization

complex Hermitian positive definite band matrix: zpbtrf()

complex Hermitian positive definite matrix: zpotrf()

complex Hermitian positive definite matrix, packed storage: zpptrf()

complex Hermitian positive definite matrix, RFP storage: zpftrf()

complex Hermitian positive semidefinite matrix: zpstrf()

or factorization

real symmetric positive definite band matrix: dpbtrf()

real symmetric positive definite matrix: dpotrf()

real symmetric positive definite matrix, packed storage: dpptrf()

real symmetric positive definite matrix, RFP storage: dpftrf()

real symmetric positive semidefinite matrix: dpstrf()

factorization

complex band matrix: zgbtrf()

complex matrix: zgetrf()

complex tridiagonal matrix: zgttrf()

real band matrix: dgbtrf()

real matrix: dgetrf()

real tridiagonal matrix: dgttrf()

Matrix inversion

after factorizing the matrix of coefficients

complex Hermitian indefinite matrix: zhetri()

complex Hermitian indefinite matrix, packed storage: zhptri()

complex Hermitian positive definite matrix: zpotri()

complex Hermitian positive definite matrix, packed storage: zpptri()

complex Hermitian positive definite matrix, RFP storage: zpftri()

complex matrix: zgetri()

complex symmetric indefinite matrix: zsytri()

complex symmetric indefinite matrix, packed storage: zsptri()

real matrix: dgetri()

real symmetric indefinite matrix: dsytri()

real symmetric indefinite matrix, packed storage: dsptri()

real symmetric positive definite matrix: dpotri()

real symmetric positive definite matrix, packed storage: dpptri()

real symmetric positive definite matrix, RFP storage: dpftri()

complex triangular matrix: ztrtri()

complex triangular matrix, packed storage: ztptri()

complex triangular matrix, RFP storage

expert driver: ztftri()

real triangular matrix: dtrtri()

real triangular matrix, packed storage: dtptri()

real triangular matrix, RFP storage

expert driver: dtftri()

or factorization

complex Hermitian indefinite matrix: zhetrf()

complex Hermitian indefinite matrix, packed storage: zhptrf()

or factorization

complex symmetric indefinite matrix: zsytrf()

complex symmetric indefinite matrix, packed storage: zsptrf()

real symmetric indefinite matrix: dsytrf()

real symmetric indefinite matrix, packed storage: dsptrf()

Solution of simultaneous linear equations

after factorizing the matrix of coefficients

complex band matrix: zgbtrs()

complex Hermitian indefinite matrix: zhetrs()

complex Hermitian indefinite matrix, packed storage: zhptrs()

complex Hermitian positive definite band matrix: zpbtrs()

complex Hermitian positive definite matrix: zpotrs()

complex Hermitian positive definite matrix, packed storage: zpptrs()

complex Hermitian positive definite matrix, RFP storage: zpftrs()

complex Hermitian positive definite tridiagonal matrix: zpttrs()

complex matrix: zgetrs()

complex symmetric indefinite matrix: zsytrs()

complex symmetric indefinite matrix, packed storage: zsptrs()

complex tridiagonal matrix: zgttrs()

real band matrix: dgbtrs()

real matrix: dgetrs()

real symmetric indefinite matrix: dsytrs()

real symmetric indefinite matrix, packed storage: dsptrs()

real symmetric positive definite band matrix: dpbtrs()

real symmetric positive definite matrix: dpotrs()

real symmetric positive definite matrix, packed storage: dpptrs()

real symmetric positive definite matrix, RFP storage: dpftrs()

real symmetric positive definite tridiagonal matrix: dpttrs()

real tridiagonal matrix: dgttrs()

expert drivers (with condition and error estimation)

complex band matrix: zgbsvx()

complex Hermitian indefinite matrix: zhesvx()

complex Hermitian indefinite matrix, packed storage: zhpsvx()

complex Hermitian positive definite band matrix: zpbsvx()

complex Hermitian positive definite matrix: zposvx()

complex Hermitian positive definite matrix, packed storage: zppsvx()

complex Hermitian positive definite tridiagonal matrix: zptsvx()

complex matrix: zgesvx()

complex symmetric indefinite matrix: zsysvx()

complex symmetric indefinite matrix, packed storage: zspsvx()

complex tridiagonal matrix: zgtsvx()

real band matrix: dgbsvx()

real matrix: dgesvx()

real symmetric indefinite matrix: dsysvx()

real symmetric indefinite matrix, packed storage: dspsvx()

real symmetric positive definite band matrix: dpbsvx()

real symmetric positive definite matrix: dposvx()

real symmetric positive definite matrix, packed storage: dppsvx()

real symmetric positive definite tridiagonal matrix: dptsvx()

real tridiagonal matrix: dgtsvx()

simple drivers

complex band matrix: zgbsv()

complex Hermitian indefinite matrix: zhesv()

complex Hermitian indefinite matrix, packed storage: zhpsv()

complex Hermitian positive definite band matrix: zpbsv()

complex Hermitian positive definite matrix: zposv()

complex Hermitian positive definite matrix, packed storage: zppsv()

complex Hermitian positive definite matrix, using mixed precision: zcposv()

complex Hermitian positive definite tridiagonal matrix: zptsv()

complex matrix: zgesv()

complex matrix, using mixed precision: zcgesv()

complex symmetric indefinite matrix: zsysv()

complex symmetric indefinite matrix, packed storage: zspsv()

complex triangular band matrix: ztbtrs()

complex triangular matrix: ztrtrs()

complex triangular matrix, packed storage: ztptrs()

complex tridiagonal matrix: zgtsv()

real band matrix: dgbsv()

real matrix: dgesv()

real matrix, using mixed precision: dsgesv()

real symmetric indefinite matrix: dsysv()

real symmetric indefinite matrix, packed storage: dspsv()

real symmetric positive definite band matrix: dpbsv()

real symmetric positive definite matrix: dposv()

real symmetric positive definite matrix, packed storage: dppsv()

real symmetric positive definite matrix, using mixed precision: dsposv()

real symmetric positive definite tridiagonal matrix: dptsv()

real triangular band matrix: dtbtrs()

real triangular matrix: dtrtrs()

real triangular matrix, packed storage: dtptrs()

real tridiagonal matrix: dgtsv()

For full information please refer to the NAG Library document

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

naginterfaces.library.lapacklin.dgbcon(norm, kl, ku, ab, ipiv, anorm)[source]

dgbcon estimates the condition number of a real band matrix , where has been factorized by dgbtrf().

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

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

Parameters
norm : str, length 1

Indicates whether or is estimated.

or

is estimated.

is estimated.
kl : int
, the number of subdiagonals within the band of the matrix .
ku : int
, the number of superdiagonals within the band of the matrix .
ab : float, array-like, shape
The factorization of , as returned by dgbtrf().
ipiv : int, array-like, shape
The pivot indices, as returned by dgbtrf().
anorm : float

If or , the -norm of the original matrix .

If , the -norm of the original matrix .

may be computed by calling blas.dlangb with the same value for the argument .

must be computed either before calling dgbtrf() or else from a copy of the original matrix .

Returns
rcond : float
An estimate of the reciprocal of the condition number of . is set to zero if exact singularity is detected or the estimate underflows. If is less than machine precision, is singular to working precision.
Raises
NagValueError
(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: .

(errno )

On entry, error in parameter .

Constraint: .

References
Higham, N J, 1988, FORTRAN codes for estimating the one-norm of a real or complex matrix, with applications to condition estimation, ACM Trans. Math. Software (14), 381–396
naginterfaces.library.lapacklin.dgbequ(m, kl, ku, ab)[source]

dgbequ computes diagonal scaling matrices and intended to equilibrate a real by band matrix of band width , and reduce its condition number.

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

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

Parameters
m : int
, the number of rows of the matrix .
kl : int
, the number of subdiagonals of the matrix .
ku : int
, the number of superdiagonals of the matrix .
ab : float, array-like, shape

The by band matrix whose scaling factors are to be computed.

See Further Comments for further details.

Returns
r : float, ndarray, shape
If no exception or warning is raised or > , contains the row scale factors, the diagonal elements of . The elements of will be positive.
c : float, ndarray, shape
If no exception or warning is raised, contains the column scale factors, the diagonal elements of . The elements of will be positive.
rowcnd : float
If no exception or warning is raised or > , contains the ratio of the smallest value of to the largest value of . If and is neither too large nor too small, it is not worth scaling by .
colcnd : float

If no exception or warning is raised, contains the ratio of the smallest value of to the largest value of .

If , it is not worth scaling by .

amax : float
. If is very close to overflow or underflow, the matrix should be scaled.
Raises
NagValueError
(errno )

On entry, error in parameter .

Constraint: .

(errno )

On entry, error in parameter .

Constraint: .

(errno )

On entry, error in parameter .

Constraint: .

(errno )

On entry, error in parameter .

Constraint: .

Warns
NagAlgorithmicWarning
(errno )
Row of is exactly zero.
(errno )
Column of is exactly zero.
naginterfaces.library.lapacklin.dgbrfs(trans, kl, ku, nrhs, ab, afb, ipiv, b, x)[source]

dgbrfs returns error bounds for the solution of a real band system of linear equations with multiple right-hand sides, or . It improves the solution by iterative refinement, in order to reduce the backward error as much as possible.

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

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

Parameters
trans : str, length 1

Indicates the form of the linear equations for which is the computed solution.

The linear equations are of the form .

or

The linear equations are of the form .
kl : int
, the number of subdiagonals within the band of the matrix .
ku : int
, the number of superdiagonals within the band of the matrix .
nrhs : int
, the number of right-hand sides.
ab : float, array-like, shape

The original by band matrix as supplied to dgbtrf() but with reduced requirements since the matrix is not factorized.

See Further Comments for further details.

afb : float, array-like, shape
The factorization of , as returned by dgbtrf().
ipiv : int, array-like, shape
The pivot indices, as returned by dgbtrf().
b : float, array-like, shape
The by right-hand side matrix .
x : float, array-like, shape
The by solution matrix , as returned by dgbtrs().
Returns
x : float, ndarray, shape
The improved solution matrix .
ferr : float, ndarray, shape
contains an estimated error bound for the th solution vector, that is, the th column of , for .
berr : float, ndarray, shape
contains the component-wise backward error bound for the th solution vector, that is, the th column of , for .
Raises
NagValueError
(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: .

(errno )

On entry, error in parameter .

Constraint: .

References
Golub, G H and Van Loan, C F, 1996, Matrix Computations, (3rd Edition), Johns Hopkins University Press, Baltimore
naginterfaces.library.lapacklin.dgbsv(kl, ku, ab, b)[source]

dgbsv computes the solution to a real system of linear equations

where is an by band matrix, with subdiagonals and superdiagonals, and and are by matrices.

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

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

Parameters
kl : int
, the number of subdiagonals within the band of the matrix .
ku : int
, the number of superdiagonals within the band of the matrix .
ab : float, array-like, shape

The by coefficient matrix .

See Further Comments for further details.

b : float, array-like, shape
The by right-hand side matrix .
Returns
ab : float, ndarray, shape
If >= 0, is overwritten by details of the factorization.
ipiv : int, ndarray, shape
If no constraints are violated, the pivot indices that define the permutation matrix ; at the th step row of the matrix was interchanged with row . indicates a row interchange was not required.
b : float, ndarray, shape
If no exception or warning is raised, the by solution matrix .
Raises
NagValueError
(errno )

On entry, error in parameter .

Constraint: .

(errno )

On entry, error in parameter .

Constraint: .

(errno )

On entry, error in parameter .

Constraint: .

(errno )

On entry, error in parameter .

Constraint: .

Warns
NagAlgorithmicWarning
(errno )
Element of the diagonal is exactly zero. The factorization has been completed, but the factor is exactly singular, so the solution could not be computed.
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

naginterfaces.library.lapacklin.dgbsvx(fact, trans, n, kl, ku, nrhs, ab, afb, ipiv, equed, r, c, b)[source]

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

where is an by band matrix with subdiagonals and superdiagonals, and and are by matrices. Error bounds on the solution and a condition estimate are also provided.

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

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

Parameters
fact : str, 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.
trans : str, length 1

Specifies the form of the system of equations.

(No transpose).

or

(Transpose).
n : int
, the number of linear equations, i.e., the order of the matrix .
kl : int
, the number of subdiagonals within the band of the matrix .
ku : int
, the number of superdiagonals within the band of the matrix .
nrhs : int
, the number of right-hand sides, i.e., the number of columns of the matrix .
ab : float, array-like, shape

The by coefficient matrix .

See Further Comments for further details.

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

afb : float, array-like, shape

If or , need not be set.

If , details of the factorization of the by band matrix , as computed by dgbtrf().

If , is the factorized form of the equilibrated matrix .

ipiv : int, array-like, shape

If or , need not be set.

If , contains the pivot indices from the factorization , as computed by dgbtrf(); row of the matrix was interchanged with row .

equed : 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 .

r : float, array-like, shape

If or , need not be set.

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

c : float, array-like, shape

If or , need not be set.

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

b : float, array-like, shape
The by right-hand side matrix .
Returns
ab : float, ndarray, shape

If or , or if and , is not modified.

If then, if no constraints are violated, is scaled as follows:

if , ;

if , ;

if , .

afb : float, ndarray, shape

If , is unchanged from entry.

Otherwise, if no constraints are violated, then if , returns details of the factorization of the band matrix , and if , returns details of the factorization of the equilibrated band matrix (see the description of for the form of the equilibrated matrix).

ipiv : int, ndarray, shape

If , is unchanged from entry.

Otherwise, if no constraints are violated, contains the pivot indices that define the permutation matrix ; at the th step row of the matrix was interchanged with row . indicates a row interchange was not required.

If , the pivot indices are those corresponding to the factorization of the original matrix .

If , the pivot indices are those corresponding to the factorization of of the equilibrated matrix .

equed : 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.

r : 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.

c : 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.

b : float, ndarray, shape

If , is not modified.

If and or , is overwritten by .

If or and or , is overwritten by .

x : float, ndarray, shape
If the function exits successfully or = + 1, the by 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 .
rcond : float
If no constraints are violated, an estimate of the reciprocal condition number of the matrix (after equilibration if that is performed), computed as .
ferr : float, 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.
berr : float, 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_factor : float
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: .

(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.
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

naginterfaces.library.lapacklin.dgbtrf(m, kl, ku, ab)[source]

dgbtrf computes the factorization of a real by band matrix.

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

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

Parameters
m : int
, the number of rows of the matrix .
kl : int
, the number of subdiagonals within the band of the matrix .
ku : int
, the number of superdiagonals within the band of the matrix .
ab : float, array-like, shape

The by matrix .

See Further Comments for further details.

Returns
ab : float, ndarray, shape
If >= 0, is overwritten by details of the factorization.
ipiv : int, ndarray, shape
The pivot indices that define the permutation matrix. At the th step, if then row of the matrix was interchanged with row , for . indicates that, at the th step, a row interchange was not required.
Raises
NagValueError
(errno )

On entry, error in parameter .

Constraint: .

(errno )

On entry, error in parameter .

Constraint: .

(errno )

On entry, error in parameter .

Constraint: .

(errno )

On entry, error in parameter .

Constraint: .

Warns
NagAlgorithmicWarning
(errno )
Element of the diagonal is exactly zero. The factorization has been completed, but the factor is exactly singular, and division by zero will occur if it is used to solve a system of equations.
References
Golub, G H and Van Loan, C F, 1996, Matrix Computations, (3rd Edition), Johns Hopkins University Press, Baltimore
naginterfaces.library.lapacklin.dgbtrs(trans, kl, ku, ab, ipiv, b)[source]

dgbtrs solves a real band system of linear equations with multiple right-hand sides,

where has been factorized by dgbtrf().

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

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

Parameters
trans : str, length 1

Indicates the form of the equations.

is solved for .

or

is solved for .
kl : int
, the number of subdiagonals within the band of the matrix .
ku : int
, the number of superdiagonals within the band of the matrix .
ab : float, array-like, shape
The factorization of , as returned by dgbtrf().
ipiv : int, array-like, shape
The pivot indices, as returned by dgbtrf().
b : float, array-like, shape
The by right-hand side matrix .
Returns
b : float, ndarray, shape
The by solution matrix .
Raises
NagValueError
(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: .

(errno )

On entry, error in parameter .

Constraint: .

References
Golub, G H and Van Loan, C F, 1996, Matrix Computations, (3rd Edition), Johns Hopkins University Press, Baltimore
naginterfaces.library.lapacklin.dgecon(norm, n, a, anorm)[source]

dgecon estimates the condition number of a real matrix , where has been factorized by dgetrf().

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

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

Parameters
norm : str, length 1

Indicates whether or is estimated.

or

is estimated.

is estimated.
n : int
, the order of the matrix .
a : float, array-like, shape
The factorization of , as returned by dgetrf().
anorm : float

If or , the -norm of the original matrix .

If , the -norm of the original matrix .

may be computed by calling blas.dlange with the same value for the argument .

must be computed either before calling dgetrf() or else from a copy of the original matrix .

Returns
rcond : float
An estimate of the reciprocal of the condition number of . is set to zero if exact singularity is detected or the estimate underflows. If is less than machine precision, is singular to working precision.
Raises
NagValueError
(errno )

On entry, error in parameter .

Constraint: , or .

(errno )

On entry, error in parameter .

Constraint: .

(errno )

On entry, error in parameter .

Constraint: .

References
Higham, N J, 1988, FORTRAN codes for estimating the one-norm of a real or complex matrix, with applications to condition estimation, ACM Trans. Math. Software (14), 381–396
naginterfaces.library.lapacklin.dgeequ(a)[source]

dgeequ computes diagonal scaling matrices and intended to equilibrate a real by matrix and reduce its condition number.

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

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

Parameters
a : float, array-like, shape
The matrix whose scaling factors are to be computed.
Returns
r : float, ndarray, shape
If no exception or warning is raised or > , contains the row scale factors, the diagonal elements of . The elements of will be positive.
c : float, ndarray, shape
If no exception or warning is raised, contains the column scale factors, the diagonal elements of . The elements of will be positive.
rowcnd : float
If no exception or warning is raised or > , contains the ratio of the smallest value of to the largest value of . If and is neither too large nor too small, it is not worth scaling by .
colcnd : float

If no exception or warning is raised, contains the ratio of the smallest value of to the largest value of .

If , it is not worth scaling by .

amax : float
. If is very close to overflow or underflow, the matrix should be scaled.
Raises
NagValueError
(errno )

On entry, error in parameter .

Constraint: .

(errno )

On entry, error in parameter .

Constraint: .

Warns
NagAlgorithmicWarning
(errno )
Row of is exactly zero.
(errno )
Column of is exactly zero.
naginterfaces.library.lapacklin.dgerfs(trans, n, a, af, ipiv, b, x)[source]

dgerfs returns error bounds for the solution of a real system of linear equations with multiple right-hand sides, or . It improves the solution by iterative refinement, in order to reduce the backward error as much as possible.

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

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

Parameters
trans : str, length 1

Indicates the form of the linear equations for which is the computed solution.

The linear equations are of the form .

or

The linear equations are of the form .
n : int
, the order of the matrix .
a : float, array-like, shape
The by original matrix as supplied to dgetrf().
af : float, array-like, shape
The factorization of , as returned by dgetrf().
ipiv : int, array-like, shape
The pivot indices, as returned by dgetrf().
b : float, array-like, shape
The by right-hand side matrix .
x : float, array-like, shape
The by solution matrix , as returned by dgetrs().
Returns
x : float, ndarray, shape
The improved solution matrix .
ferr : float, ndarray, shape
contains an estimated error bound for the th solution vector, that is, the th column of , for .
berr : float, ndarray, shape
contains the component-wise backward error bound for the th solution vector, that is, the th column of , for .
Raises
NagValueError
(errno )

On entry, error in parameter .

Constraint: , or .

(errno )

On entry, error in parameter .

Constraint: .

(errno )

On entry, error in parameter .

Constraint: .

References
Golub, G H and Van Loan, C F, 1996, Matrix Computations, (3rd Edition), Johns Hopkins University Press, Baltimore
naginterfaces.library.lapacklin.dgesv(a, b)[source]

dgesv computes the solution to a real system of linear equations

where is an by matrix and and are by matrices.

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

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

Parameters
a : float, array-like, shape
The by coefficient matrix .
b : float, array-like, shape
The by right-hand side matrix .
Returns
a : float, ndarray, shape
The factors and from the factorization ; the unit diagonal elements of are not stored.
ipiv : int, ndarray, shape
If no constraints are violated, the pivot indices that define the permutation matrix ; at the th step row of the matrix was interchanged with row . indicates a row interchange was not required.
b : float, ndarray, shape
If no exception or warning is raised, the by solution matrix .
Raises
NagValueError
(errno )

On entry, error in parameter .

Constraint: .

(errno )

On entry, error in parameter .

Constraint: .

Warns
NagAlgorithmicWarning
(errno )
Element of the diagonal is exactly zero. The factorization has been completed, but the factor is exactly singular, so the solution could not be computed.
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

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 by matrix and and are by 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/flhtml/f07/f07abf.html

Parameters
fact : str, 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.
trans : str, length 1

Specifies the form of the system of equations.

(No transpose).

or

(Transpose).
n : int
, the number of linear equations, i.e., the order of the matrix .
nrhs : int
, the number of right-hand sides, i.e., the number of columns of the matrix .
a : float, array-like, shape

The by matrix .

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

equed : None 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 .

b : float, array-like, shape
The by right-hand side matrix .
af : None 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.

ipiv : None 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.

r : None 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.

c : None 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
a : float, ndarray, shape

If or , or if and , is not modified.

If or , is scaled as follows:

if , ;

if , ;

if , .

af : None 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.

ipiv : None 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.

equed : None 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.

r : None 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.

c : None 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.

b : float, ndarray, shape

If , is not modified.

If and or , is overwritten by .

If or and or , is overwritten by .

x : float, ndarray, shape
If the function exits successfully or = + 1, the by 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 .
rcond : float
If no constraints are violated, an estimate of the reciprocal condition number of the matrix (after equilibration if that is performed), computed as .
ferr : float, 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.
berr : float, 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_factor : float
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.
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

naginterfaces.library.lapacklin.dgetrf(a)[source]

dgetrf computes the factorization of a real by matrix.

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

Parameters
a : float, array-like, shape
The by matrix .
Returns
a : float, ndarray, shape
The factors and from the factorization ; the unit diagonal elements of are not stored.
ipiv : int, ndarray, shape
The pivot indices that define the permutation matrix. At the th step, if then row of the matrix was interchanged with row , for . indicates that, at the th step, a row interchange was not required.
Raises
NagValueError
(errno )

On entry, error in parameter .

Constraint: .

(errno )

On entry, error in parameter .

Constraint: .

Warns
NagAlgorithmicWarning
(errno )
Element of the diagonal is exactly zero. The factorization has been completed, but the factor is exactly singular, and division by zero will occur if it is used to solve a system of equations.
References
Golub, G H and Van Loan, C F, 1996, Matrix Computations, (3rd Edition), Johns Hopkins University Press, Baltimore
naginterfaces.library.lapacklin.dgetri(a, ipiv)[source]

dgetri computes the inverse of a real matrix , where has been factorized by dgetrf().

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

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

Parameters
a : float, array-like, shape
The factorization of , as returned by dgetrf().
ipiv : int, array-like, shape
The pivot indices, as returned by dgetrf().
Returns
a : float, ndarray, shape
The factorization is overwritten by the by matrix .
Raises
NagValueError
(errno )

On entry, error in parameter .

Constraint: .

Warns
NagAlgorithmicWarning
(errno )
Element of the diagonal is zero. is singular, and the inverse of cannot be computed.
References
Du Croz, J J and Higham, N J, 1992, Stability of methods for matrix inversion, IMA J. Numer. Anal. (12), 1–19
naginterfaces.library.lapacklin.dgetrs(trans, a, ipiv, b)[source]

dgetrs solves a real system of linear equations with multiple right-hand sides,

where has been factorized by dgetrf().

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

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

Parameters
trans : str, length 1

Indicates the form of the equations.

is solved for .

or

is solved for .
a : float, array-like, shape
The factorization of , as returned by dgetrf().
ipiv : int, array-like, shape
The pivot indices, as returned by dgetrf().
b : float, array-like, shape
The by right-hand side matrix .
Returns
b : float, ndarray, shape
The by solution matrix .
Raises
NagValueError
(errno )

On entry, error in parameter .

Constraint: , or .

(errno )

On entry, error in parameter .

Constraint: .

(errno )

On entry, error in parameter .

Constraint: .

References
Golub, G H and Van Loan, C F, 1996, Matrix Computations, (3rd Edition), Johns Hopkins University Press, Baltimore
naginterfaces.library.lapacklin.dgtcon(norm, n, dl, d, du, du2, ipiv, anorm)[source]

dgtcon estimates the reciprocal condition number of a real by tridiagonal matrix , using the factorization returned by dgttrf().

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

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

Parameters
norm : str, length 1

Specifies the norm to be used to estimate .

or

Estimate .

Estimate .
n : int
, the order of the matrix .
dl : float, array-like, shape
Must contain the multipliers that define the matrix of the factorization of .
d : float, array-like, shape
Must contain the diagonal elements of the upper triangular matrix from the factorization of .
du : float, array-like, shape
Must contain the elements of the first superdiagonal of .
du2 : float, array-like, shape
Must contain the elements of the second superdiagonal of .
ipiv : int, array-like, shape
Must contain the pivot indices that define the permutation matrix . At the th step, row of the matrix was interchanged with row , and must always be either or , indicating that a row interchange was not performed.
anorm : float

If or , the -norm of the original matrix .

If , the -norm of the original matrix .

may be computed by calling blas.dlangt with the same value for the argument .

must be computed either before calling dgttrf() or else from a copy of the original matrix .

Returns
rcond : float
Contains an estimate of the reciprocal condition number.
Raises
NagValueError
(errno )

On entry, error in parameter .

Constraint: ,