XLPack 7.0
XLPack Numerical Library (C API) Reference Manual
Loading...
Searching...
No Matches

◆ dgelsy()

void dgelsy ( int  m,
int  n,
int  nrhs,
int  lda,
double  a[],
int  ldb,
double  b[],
int  jpvt[],
double  rcond,
int *  rank,
double  work[],
int  lwork,
int *  info 
)

Solution to overdetermined or underdetermined linear equations Ax = b using a complete orthogonal factorization

Purpose
dgelsy computes the minimum-norm solution to a real linear least squares problem:
minimize || A * X - B ||
using a complete orthogonal factorization of A. A is an m x n matrix which may be rank-deficient.
Several right hand side vectors b and solution vectors x can be handled in a single call; they are stored as the columns of the m x nrhs right hand side matrix B and the n x nrhs solution matrix X.

The routine first computes a QR factorization with column pivoting:
A * P = Q * [ R11 R12 ]
[ 0 R22 ]
with R11 defined as the largest leading submatrix whose estimated condition number is less than 1/rcond. The order of R11, rank, is the effective rank of A.
Then, R22 is considered to be negligible, and R12 is annihilated by orthogonal transformations from the right, arriving at the complete orthogonal factorization:
A * P = Q * [ T11 0 ] * Z
[ 0 0 ]
The minimum-norm solution is then
X = P * Z^T [ T11^(-1)*Q1^T*B ]
[ 0 ]
where Q1 consists of the first rank columns of Q.
Parameters
[in]mNumber of rows of the matrix A. (m >= 0) (If m = 0, returns with rank = 0)
[in]nNumber of columns of the matrix A. (n >= 0) (If n = 0, returns with rank = 0)
[in]nrhsNumber of right hand sides, i.e., number of columns of the matrices B and X. (nrhs >= 0) (If nrhs = 0, returns with rank = 0)
[in]ldaLeading dimension of the two dimensional array a[][]. (lda >= max(1, m))
[in,out]a[][]Array a[la][lda] (la >= n)
[in] m x n matrix A.
[out] a[][] has been overwritten by details of the complete orthogonal factorization.
[in]ldbLeading dimension of the two dimensional array b[][]. (ldb >= max(1, m, n))
[in,out]b[][]Array b[lb][ldb] (lb >= nrhs)
[in] m x nrhs right hand side matrix B.
[out] n x nrhs solution matrix X.
[in,out]jpvt[]Array jpvt[ljpvt] (ljpvt >= n)
[in] If jpvt[i-1] != 0, the i-th column of A is permuted to the front of A*P, otherwise column i is a free column.
[out] If jpvt[i-1] = k, then the i-th column of A*P was the k-th column of A.
[in]rcondrcond is used to determine the effective rank of A, which is defined as the order of the largest leading triangular submatrix R11 in the QR factorization with pivoting of A, whose estimated condition number < 1/rcond.
[out]rankThe effective rank of A, i.e., the order of the submatrix R11. This is the same as the order of the submatrix T11 in the complete orthogonal factorization of A.
[out]work[]Array work[lwork]
Work array.
On exit, if info = 0, work[0] returns the optimal lwork.
[in]lworkThe dimension of the array work[].
The unblocked strategy requires lwork >= max(1, mn+3*n+1, 2*mn+nrhs) where mn = min(m, n).
The block algorithm requires lwork >= max(1, mn+2*n+nb*(n+1), 2*mn+nb*nrhs) where nb is an upper bound on the blocksize.
If lwork = -1, then a workspace query is assumed. The routine only calculates the optimal size of the work[] array, and returns the value in work[0].
[out]info= 0: Successful exit
= -1: The argument m had an illegal value (m < 0)
= -2: The argument n had an illegal value (n < 0)
= -3: The argument nrhs had an illegal value (nrhs < 0)
= -4: The argument lda had an illegal value (lda < max(1, m))
= -6: The argument ldb had an illegal value (ldb < max(1, m, n))
= -12: The argument lwork had an illegal value (lwork too small)
Reference
LAPACK