- naginterfaces.library.linsys.real_gen_lsqsol(a, b, eps)¶
real_gen_lsqsolcalculates 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
- afloat, array-like, shape
The matrix .
- bfloat, array-like, shape
The right-hand side matrix .
Must be set to the value of the machine precision.
- 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.
- (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.
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_lsqsolfirst 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.
Wilkinson, J H and Reinsch, C, 1971, Handbook for Automatic Computation II, Linear Algebra, Springer–Verlag