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

◆ zgetsls()

void zgetsls ( char  trans,
int  m,
int  n,
int  nrhs,
int  lda,
doublecomplex  a[],
int  ldb,
doublecomplex  b[],
doublecomplex  work[],
int  lwork,
int *  info 
)

Solution to overdetermined or underdetermined linear equations Ax = b for complex matrices (Full rank) (Tall skinny QR or short wide LQ factorization)

Purpose
This routine solves overdetermined or underdetermined real linear systems involving an m x n matrix A, using a tall skinny QR or short wide LQ factorization of A. It is assumed that A has full rank.

The following options are provided:

  1. If trans = 'N' and m >= n: find the least squares solution of an overdetermined system, i.e., solve the least squares problem
    minimize || B - A*X ||.
  2. If trans = 'N' and m < n: find the minimum norm solution of an underdetermined system A * X = B.
  3. If trans = 'T' and m >= n: find the minimum norm solution of an underdetermined system A^H * X = B.
  4. If trans = 'T' and m < n: find the least squares solution of an overdetermined system, i.e., solve the least squares problem
    minimize || B - A^H*X ||.

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.
Parameters
[in]trans= 'N': The linear system involves A.
= 'T': The linear system involves A^H.
[in]mNumber of rows of the matrix A. (m >= 0) (If m = 0, returns zero vectors in b[][])
[in]nNumber of columns of the matrix A. (n >= 0) (If n = 0, returns zero vectors in b[][])
[in]nrhsNumber of right hand sides, i.e., number of columns of the matrices B and X. (nrhs >= 0) (If nrhs = 0, returns without computation)
[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[][] is overwritten by details of its QR or LQ factorization as returned by zgeqr or zgelq.
[in]ldbLeading dimension of the two dimensional array b[][]. (ldb >= max(1, m, n))
[in,out]b[][]Array b[lb][ldb] (lb >= nrhs)
[in] Matrix B of right hand side vectors, stored columnwise; B is m x nrhs if trans = 'N', or n x nrhs if trans = 'T'.
[out] If info = 0, b[][] is overwritten by the solution vectors, stored columnwise:
  trans = 'N' and m >= n: Rows 0 to n-1 of b[][] contain the least squares solution vectors.
  trans = 'N' and m < n: Rows 0 to n-1 of b[][] contain the minimum norm solution vectors.
  trans = 'T' and m >= n: Rows 0 to m-1 of b[][] contain the minimum norm solution vectors.
  trans = 'T' and m < n: Rows 0 to m-1 of b[][] contain the least squares solution vectors.
[out]work[]Array work[lwork]
Work array.
On exit, if info = 0, work[0] contains optimal (or either minimal or optimal, if query was assumed) lwork. See lwork for details.
[in]lworkThe dimension of the array work[].
If lwork = -1 or -2, then a workspace query is assumed.
If lwork = -1, the routine calculates optimal size of work[] for the optimal performance and returns this value in work[0].
If lwork = -2, the routine calculates minimal size of work[] and returns this value in work[0].
[out]info= 0: Successful exit
= -1: The argument trans had an illegal value (trans != 'T' nor 'N')
= -2: The argument m had an illegal value (m < 0)
= -3: The argument n had an illegal value (n < 0)
= -4: The argument nrhs had an illegal value (nrhs < 0)
= -5: The argument lda had an illegal value (lda < max(1, m))
= -7: The argument ldb had an illegal value (ldb < max(1, m, n))
= -10: The argument lwork had an illegal value (lwork too small)
= i > 0: The i-th diagonal element of the triangular factor of A is zero, so that A does not have full rank. The least squares solution could not be computed.
Reference
LAPACK