naginterfaces.library.linsys.real_​gen_​lsqsol

naginterfaces.library.linsys.real_gen_lsqsol(a, b, eps)[source]

real_gen_lsqsol calculates the accurate least squares solution of a set of linear equations in unknowns, and rank , with multiple right-hand sides, , using a factorization and iterative refinement.

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

https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/f04/f04amf.html

Parameters
afloat, array-like, shape

The matrix .

bfloat, array-like, shape

The right-hand side matrix .

epsfloat

Must be set to the value of the machine precision.

Returns
xfloat, ndarray, shape

The solution matrix .

qrfloat, ndarray, shape

Details of the factorization.

alphafloat, ndarray, shape

The diagonal elements of the upper triangular matrix .

ipivint, ndarray, shape

Details of the column interchanges.

Warns
NagAlgorithmicWarning
(errno )

The rank of is less than . The problem does not have a unique solution.

(errno )

The iterative refinement fails to converge. The matrix is too ill-conditioned.

Notes

No equivalent traditional C interface for this routine exists in the NAG Library.

To compute the least squares solution to a set of linear equations in unknowns , real_gen_lsqsol first computes a factorization of with column pivoting, , where is upper triangular, is an orthogonal matrix, and is a permutation matrix. is applied to the right-hand side matrix to give , and the solution matrix is calculated, to a first approximation, by back-substitution in . The residual matrix is calculated using additional precision, and a correction to is computed as the least squares solution to . is replaced by and this iterative refinement of the solution is repeated until full machine accuracy has been obtained.

References

Wilkinson, J H and Reinsch, C, 1971, Handbook for Automatic Computation II, Linear Algebra, Springer–Verlag