Function
NumCosmoMathlapack_dgelsd
Declaration [src]
gint
ncm_lapack_dgelsd (
const gint m,
const gint n,
const gint nrhs,
gdouble* a,
const gint lda,
gdouble* b,
const gint ldb,
gdouble* s,
gdouble* rcond,
gint* rank,
NcmLapackWS* ws
)
Description [src]
DGELSD computes the minimum-norm solution to a real linear least squares problem: minimize 2-norm(| b - A*x |) using the singular value decomposition (SVD) of A. A is an M-by-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-by-NRHS right hand side matrix B and the N-by-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.
The divide and conquer algorithm makes very mild assumptions about floating point arithmetic. It will work on machines with a guard digit in add/subtract, or on those binary machines without guard digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or Cray-2. It could conceivably fail on hexadecimal or decimal machines without guard digits, but we know of none.
Parameters
m-
Type:
const gintIs an integer. The number of rows of the matrix A. M >= 0.
n-
Type:
const gintIs an integer. The number of columns of the matrix A. N >= 0.
nrhs-
Type:
const gintIs an integer. The number of right hand sides, i.e., the number of columns of the matrices B and X. NRHS >=0.
a-
Type:
gdouble*Array of doubles with dimension (
n,lda) On entry, the M-by-N matrix A. On exit, if M >= N, A is overwritten by details of its QR factorization as returned by DGEQRF if M < N, A is overwritten by details of its LQ factorization as returned by DGELQF.The data is owned by the caller of the function. lda-
Type:
const gintThe leading dimension of the array
a,lda>= max (1,n). b-
Type:
gdouble*Array of doubles with dimension (
n,ldb) On entry, the matrix B of right hand side vectors, stored columnwise; B is M-by-NRHS if TRANS = ‘N’, or N-by-NRHS if TRANS = ‘T’. On exit, if INFO = 0, B is overwritten by the solution vectors, stored columnwise: if TRANS = ‘N’ and m >= n, rows 1 to n of B contain the least squares solution vectors; the residual sum of squares for the solution in each column is given by the sum of squares of elements N+1 to M in that column; if TRANS = ‘N’ and m < n, rows 1 to N of B contain the minimum norm solution vectors; if TRANS = ‘T’ and m >= n, rows 1 to M of B contain the minimum norm solution vectors; if TRANS = ‘T’ and m < n, rows 1 to M of B contain the least squares solution vectors; the residual sum of squares for the solution in each column is given by the sum of squares of elements M+1 to N in that column.The data is owned by the caller of the function. ldb-
Type:
const gintThe leading dimension of the array
b,ldb>= max (1,n). s-
Type:
gdouble*S is DOUBLE PRECISION array, dimension (min(M,N)) The singular values of A in decreasing order. The condition number of A in the 2-norm = S(1)/S(min(m,n)).
The data is owned by the caller of the function. rcond-
Type:
gdouble*RCOND is DOUBLE PRECISION RCOND is used to determine the effective rank of A. Singular values S(i) <= RCOND*S(1) are treated as zero. If RCOND < 0, machine precision is used instead.
The data is owned by the caller of the function. rank-
Type:
gint*RANK is INTEGER The effective rank of A, i.e., the number of singular values which are greater than RCOND*S(1).
The data is owned by the caller of the function. ws-
Type:
NcmLapackWSA Lapack workspace object
NcmLapackWS.The data is owned by the caller of the function.