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

◆ zgelsd()

void zgelsd ( int  m,
int  n,
int  nrhs,
int  lda,
doublecomplex  a[],
int  ldb,
doublecomplex  b[],
double  s[],
double  rcond,
int *  rank,
doublecomplex  work[],
int  lwork,
double  rwork[],
int  iwork[],
int *  info 
)

Solution to overdetermined or underdetermined linear equations Ax = b for complex matrices using the singular value decomposition (SVD) (Divide and conquer method)

Purpose
This routine computes the minimum norm solution to a complex linear least squares problem:
minimize 2-norm(| b - A*x |)
using the singular value decomposition (SVD) 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 problem is solved in three steps:
(1) Reduce the coefficient matrix A to bidiagonal form with Householder transformations, reducing the original problem into a "bidiagonal least squares problem" (BLS).
(2) Solve the BLS using a divide and conquer approach.
(3) Apply back all the Householder transformations to solve the original least squares problem.

The effective rank of A is determined by treating as zero those singular values which are less than rcond times the largest singular value.
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)
[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 destroyed.
[in]ldbLeading dimension of the two dimensional array b[][]. (ldb >= max(1, max(m, n)))
[in,out]b[][]Array b[lb][ldb] (lb >= nrhs)
[in] m x nrhs right hand side matrix B.
[out] b[][] is overwritten by the n x nrhs solution matrix X. If m >= n and rank = n, the residual sum of squares for the solution in the i-th column is given by the sum of squares of elements n to m-1 in that column.
[out]s[]Array s[ls] (ls >= min(m, n))
The singular values of A in decreasing order.
The condition number of A in the 2-norm = s[0]/s[min(m, n)-1].
[in]rcondrcond is used to determine the effective rank of A.
Singular values s[i] <= rcond*s[0] are treated as zero. If rcond < 0, machine precision is used instead.
[out]rankThe effective rank of A, i.e., the number of singular values which are greater than rcond*s[0].
[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[]. (lwork must be at least 1: lwork = max(1, lwork))
The exact minimum amount of workspace needed depends on m, n and nrhs.
As long as lwork is at least
2*n + n*nrhs, if m is greater than or equal to n; or
2*m + m*nrhs, if m is less than n,
the code will execute correctly.
For good performance, LWORK should generally be larger.

If lwork = -1, then a workspace query is assumed. The routine only calculates the optimal size of the array work[] and the minimum sizes of the arrays rwork[] and iwork[], and returns these values in work[0], rwork[0] and iwork[0].
[out]rwork[]Array rwork[lrwork] (lrwork must be at least 1: lrwork = max(1, lrwork))
As long as lrwork is at least
10*n + 2*n*smlsiz + 8*n*nlvl + 3*smlsiz*nrhs + max((smlsiz + 1)^2, n*(1 + nrhs) + 2*nrhs) if m is greater than or equal to n; or
10*m + 2*m*smlsiz + 8*m*nlvl + 3*smlsiz*nrhs + max((smlsiz + 1)^2, n*(1 + nrhs) + 2*nrhs) if m is less than n,
the code will execute correctly.
smlsiz is returned by ilaenv and is equal to the maximum size of the subproblems at the bottom of the computation tree (usually about 25), and
nlvl = max(0, int(log2(min(m, n)/(smlsiz + 1))) + 1).
On exit, if info = 0, rwork[0] returns the minimum lrwork.
[out]iwork[]Array iwork[liwork] (liwork >= max(1, 3*minmn*nlvl + 11*minmn), where minmn = min(m, n))
Integer work array.
On exit, if info = 0, iwork[0] returns the minimum liwork.
[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)
= i > 0: The algorithm for computing the SVD failed to converge; i off-diagonal elements of an intermediate bidiagonal form did not converge to zero.
Reference
LAPACK