?gelsd
?gelsd
Computes the minimum-norm solution to a linear least squares problem using the singular value decomposition of A and a divide and conquer method.
Syntax
lapack_int LAPACKE_sgelsd
(
int
matrix_layout
,
lapack_int
m
,
lapack_int
n
,
lapack_int
nrhs
,
float*
a
,
lapack_int
lda
,
float*
b
,
lapack_int
ldb
,
float*
s
,
float
rcond
,
lapack_int*
rank
);
lapack_int LAPACKE_dgelsd
(
int
matrix_layout
,
lapack_int
m
,
lapack_int
n
,
lapack_int
nrhs
,
double*
a
,
lapack_int
lda
,
double*
b
,
lapack_int
ldb
,
double*
s
,
double
rcond
,
lapack_int*
rank
);
lapack_int LAPACKE_cgelsd
(
int
matrix_layout
,
lapack_int
m
,
lapack_int
n
,
lapack_int
nrhs
,
lapack_complex_float*
a
,
lapack_int
lda
,
lapack_complex_float*
b
,
lapack_int
ldb
,
float*
s
,
float
rcond
,
lapack_int*
rank
);
lapack_int LAPACKE_zgelsd
(
int
matrix_layout
,
lapack_int
m
,
lapack_int
n
,
lapack_int
nrhs
,
lapack_complex_double*
a
,
lapack_int
lda
,
lapack_complex_double*
b
,
lapack_int
ldb
,
double*
s
,
double
rcond
,
lapack_int*
rank
);
Include Files
- mkl.h
Description
The routine computes the minimum-norm solution to a real linear least squares problem:
minimize ||
b
- A
*x
||2
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:
- Reduce the coefficient matrix A to bidiagonal form with Householder transformations, reducing the original problem into a "bidiagonal least squares problem" (BLS).
- Solve the BLS using a divide and conquer approach.
- 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.Input Parameters
- matrix_layout
- Specifies whether matrix storage layout is row major (LAPACK_ROW_MAJOR) or column major (LAPACK_COL_MAJOR).
- m
- The number of rows of the matrixA().m≥0
- n
- The number of columns of the matrixA().n≥0
- nrhs
- The number of right-hand sides; the number of columns inB().nrhs≥0
- a,b
- Arrays:a(size max(1,contains thelda*n) for column major layout and max(1,lda*m) for row major layout)m-by-nmatrixA.b(size max(1,contains theldb*nrhs) for column major layout and max(1,ldb*max(m,n)) for row major layout)m-by-nrhsright hand side matrixB.
- lda
- The leading dimension ofa; at least max(1,m)for column major layout and max(1,.n) for row major layout
- ldb
- The leading dimension ofb; must be at least max(1,m,n)for column major layout and at least max(1,.nrhs) for row major layout
- rcond
- rcondis used to determine the effective rank ofA. Singular valuesare treated as zero. Ifs(i)≤rcond*s(1), machine precision is used instead.rcond≤0
Output Parameters
- a
- On exit,Ahas been overwritten.
- b
- Overwritten by then-by-nrhssolution matrixX.Ifandm≥n, the residual sum-of-squares for the solution in therank=ni-th column is given by the sum of squares of modulus of elementsn+1:min that column.
- s
- Array, size at least max(1, min(m,n)). The singular values ofAin decreasing order. The condition number ofAin the 2-norm is.k2(A) =s(1)/s(min(m,n))
- rank
- The effective rank ofA, that is, the number of singular values which are greater than.rcond*s(1)
Return Values
This function returns a value
info
.If , the execution is successful.
info
=0If , the
info
= -i
i
-th parameter had an illegal value.If , then the algorithm for computing the SVD failed to converge;
info
= i
i
indicates the number of off-diagonal elements of an intermediate bidiagonal form that did not converge to zero.