?gels
?gels
Uses QR or LQ factorization to solve a overdetermined or underdetermined linear system with full rank matrix.
Syntax
lapack_int
LAPACKE_sgels
(
int
matrix_layout
,
char
trans
,
lapack_int
m
,
lapack_int
n
,
lapack_int
nrhs
,
float
*
a
,
lapack_int
lda
,
float
*
b
,
lapack_int
ldb
);
lapack_int
LAPACKE_dgels
(
int
matrix_layout
,
char
trans
,
lapack_int
m
,
lapack_int
n
,
lapack_int
nrhs
,
double
*
a
,
lapack_int
lda
,
double
*
b
,
lapack_int
ldb
);
lapack_int
LAPACKE_cgels
(
int
matrix_layout
,
char
trans
,
lapack_int
m
,
lapack_int
n
,
lapack_int
nrhs
,
lapack_complex_float
*
a
,
lapack_int
lda
,
lapack_complex_float
*
b
,
lapack_int
ldb
);
lapack_int
LAPACKE_zgels
(
int
matrix_layout
,
char
trans
,
lapack_int
m
,
lapack_int
n
,
lapack_int
nrhs
,
lapack_complex_double
*
a
,
lapack_int
lda
,
lapack_complex_double
*
b
,
lapack_int
ldb
);
Include Files
- mkl.h
Description
The routine solves overdetermined or underdetermined real/ complex linear systems involving an
m
-by-n
matrix A
, or its transpose/ conjugate-transpose, using a QR
or LQ
factorization of A
. It is assumed that A
has full rank.The following options are provided:
1. If and : find the least squares solution of an overdetermined system, that is, solve the least squares problem
trans
= 'N'
m
≥
n
minimize ||
b
- A
*x
||2
2. If and : find the minimum norm solution of an underdetermined system .
trans
= 'N'
m
< n
A
*X
= B
3. If or : find the minimum norm solution of an undetermined system .
trans
= 'T'
'C'
and m
≥
n
A
H
*X
= B
4. If or : find the least squares solution of an overdetermined system, that is, solve the least squares problem
trans
= 'T'
'C'
and m
< n
minimize ||*
b
- A
H
x
||2
Several right hand side vectors
b
and solution vectors x
can be handled in a single call; they are formed by the columns of the right hand side matrix B
and the solution matrix X
(when coefficient matrix is A
, B
is m
-by-nrhs
and X
is n
-by-nrhs
; if the coefficient matrix is A
T
or A
H
, B
isn
-by-nrhs
and X
is m
-by-nrhs
.Input Parameters
- matrix_layout
- Specifies whether matrix storage layout is row major (LAPACK_ROW_MAJOR) or column major (LAPACK_COL_MAJOR).
- trans
- Must be'N','T', or'C'.If, the linear system involves matrixtrans='N'A;If, the linear system involves the transposed matrixtrans='T'A(for real flavors only);TIf, the linear system involves the conjugate-transposed matrixtrans='C'A(for complex flavors only).H
- 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 the matrixldb*nrhs) for column major layout and max(1,ldb*max(m,n)) for row major layout)Bof right hand side vectors.
- lda
- The leading dimension ofa; at least max(1,m)for column major layout and at least max(1,.n) for row major layout
- ldb
- The leading dimension ofb; must be at least max(1,m,n)for column major layout if.trans='N'and at leastmax(1,ifn)trans='T'and at least max(1,nrhs) for row major layout regardless of the value oftrans
Output Parameters
- a
- On exit, overwritten by the factorization data as follows:if, arraym≥nacontains the details of theQRfactorization of the matrixAas returned by?geqrf;if, arraym<nacontains the details of theLQfactorization of the matrixAas returned by?gelqf.
- b
- If,info= 0boverwritten by the solution vectors, stored columnwise:ifandtrans='N', rows 1 tom≥nnofbcontain the least squares solution vectors; the residual sum of squares for the solution in each column is given by the sum of squares of modulus of elementsn+1 tomin that column;ifandtrans='N', rows 1 tom<nnofbcontain the minimum norm solution vectors;ifortrans='T''C'and, rows 1 tom≥nmofbcontain the minimum norm solution vectors;ifortrans='T''C'and, rows 1 tom<nmofbcontain the least squares solution vectors; the residual sum of squares for the solution in each column is given by the sum of squares of modulus of elementsm+1 tonin that column.
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
info
= i
, 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.