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. They have been designed to be efficient on a wide range of high-performance computers, without compromising efficiency on conventional serial machines.

See Also

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]

Estimate condition number of real band matrix, matrix already 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 (see Example).

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

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

Computes row and column scalings intended to equilibrate a real banded matrix 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 > , this argument contains the row scale factors, the diagonal elements of . The elements of this argument will be positive.
c : float, ndarray, shape
If no exception or warning is raised, this argument contains the column scale factors, the diagonal elements of . The elements of this argument will be positive.
rowcnd : float
If no exception or warning is raised or > , this argument 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, this argument contains the ratio of the smallest value of to the largest value of .

If , it is not worth scaling by .

amax : float
. If this argument 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]

Refined solution with error bounds of real band system of linear equations, multiple right-hand sides.

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

naginterfaces.library.lapacklin.dgbsv(kl, ku, ab, b)[source]

Computes the solution to a real banded system of linear equations.

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, this argument 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.
naginterfaces.library.lapacklin.dgbsvx(fact, trans, n, kl, ku, nrhs, ab, afb, ipiv, equed, r, c, b)[source]

Uses the factorization to compute the solution, error-bound and condition estimate for a real banded system of linear equations.

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 , this argument is not modified.

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

  • if , ;
  • if , ;
  • if , .
afb : float, ndarray, shape

If , this argument is unchanged from entry.

Otherwise, if no constraints are violated, then if , this argument returns details of the factorization of the band matrix , and if , this argument 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 , this argument is unchanged from entry.

Otherwise, if no constraints are violated, this argument 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 , this argument is unchanged from entry.

Otherwise, if no constraints are violated, this argument 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 , this argument contains the row scale factors for , , such that is multiplied on the left by ; each element of is positive.

c : float, ndarray, shape

If , this argument is unchanged from entry.

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

b : float, ndarray, shape

If , this argument is not modified.

If and or , this argument is overwritten by .

If or and or , this argument 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.
naginterfaces.library.lapacklin.dgbtrf(m, kl, ku, ab)[source]

factorization of 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, this argument 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.
naginterfaces.library.lapacklin.dgbtrs(trans, kl, ku, ab, ipiv, b)[source]

Solution of real band system of linear equations, multiple right-hand sides, matrix already 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: .

naginterfaces.library.lapacklin.dgecon(norm, n, a, anorm)[source]

Estimate condition number of real matrix, matrix already 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 (see Example).

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

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

Computes row and column scalings intended to equilibrate a general real 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 > , this argument contains the row scale factors, the diagonal elements of . The elements of this argument will be positive.
c : float, ndarray, shape
If no exception or warning is raised, this argument contains the column scale factors, the diagonal elements of . The elements of this argument will be positive.
rowcnd : float
If no exception or warning is raised or > , this argument 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, this argument contains the ratio of the smallest value of to the largest value of .

If , it is not worth scaling by .

amax : float
. If this argument 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]

Refined solution with error bounds of real system of linear equations, multiple right-hand sides.

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

naginterfaces.library.lapacklin.dgesv(a, b)[source]

Computes the solution to a real system of linear equations.

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.
naginterfaces.library.lapacklin.dgesvx(fact, trans, n, nrhs, a, equed, b, af=None, ipiv=None, r=None, c=None)[source]

Uses the factorization to compute the solution, error-bound and condition estimate for a real system of linear equations.

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 , this argument is not modified.

If or , is scaled as follows:

  • if , ;
  • if , ;
  • if , .
af : None or float, ndarray, shape

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

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

If , this argument is unchanged from entry.

ipiv : None or int, ndarray, shape

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

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

If , this argument is unchanged from entry.

equed : None or str, length 1

If , this argument is unchanged from entry.

Otherwise, if no constraints are violated, this argument 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 , this argument 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 , this argument is unchanged from entry.

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

b : float, ndarray, shape

If , this argument is not modified.

If and or , this argument is overwritten by .

If or and or , this argument 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.
naginterfaces.library.lapacklin.dgetrf(a)[source]

factorization of real by matrix.

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

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

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.
naginterfaces.library.lapacklin.dgetri(a, ipiv)[source]

Inverse of real matrix, matrix already 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.
naginterfaces.library.lapacklin.dgetrs(trans, a, ipiv, b)[source]

Solution of real system of linear equations, multiple right-hand sides, matrix already 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: .

naginterfaces.library.lapacklin.dgtcon(norm, n, dl, d, du, du2, ipiv, anorm)[source]

Estimates the reciprocal of the condition number of a real tridiagonal matrix using the factorization computed 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 (see Example).

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

On entry, error in parameter .

Constraint: , or .

(errno )

On entry, error in parameter .

Constraint: .

(errno )

On entry, error in parameter .

Constraint: .

naginterfaces.library.lapacklin.dgtrfs(trans, n, nrhs, dl, d, du, dlf, df, duf, du2, ipiv, b, x)[source]

Refined solution with error bounds of real tridiagonal system of linear equations, multiple right-hand sides.

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

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

Parameters
trans : str, length 1

Specifies the equations to be solved as follows:

Solve for .

or

Solve for .
n : int
, the order of the matrix .
nrhs : int
, the number of right-hand sides, i.e., the number of columns of the matrix .
dl : float, array-like, shape
Must contain the subdiagonal elements of the matrix .
d : float, array-like, shape
Must contain the diagonal elements of the matrix .
du : float, array-like, shape
Must contain the superdiagonal elements of the matrix .
dlf : float, array-like, shape
Must contain the multipliers that define the matrix of the factorization of .
df : float, array-like, shape
Must contain the diagonal elements of the upper triangular matrix from the factorization of .
duf : 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.
b : float, array-like, shape
The by matrix of right-hand sides .
x : float, array-like, shape
The by initial solution matrix .
Returns
x : float, ndarray, shape
The by refined solution matrix .
ferr : float, ndarray, shape
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 almost always a slight overestimate of the true error.
berr : float, ndarray, shape
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).
Raises
NagValueError
(errno )

On entry, error in parameter .

Constraint: , or .

(errno )

On entry, error in parameter .

Constraint: .

(errno )

On entry, error in parameter .

Constraint: .

naginterfaces.library.lapacklin.dgtsv(dl, d, du, b)[source]

Computes the solution to a real tridiagonal system of linear equations.

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

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

Parameters
dl : float, array-like, shape
Must contain the subdiagonal elements of the matrix .
d : float, array-like, shape
Must contain the diagonal elements of the matrix .
du : float, array-like, shape
Must contain the superdiagonal elements of the matrix .
b : float, array-like, shape
The by right-hand side matrix .
Returns
dl : float, ndarray, shape
If no constraints are violated, is overwritten by the () elements of the second superdiagonal of the upper triangular matrix from the factorization of , in