Uses QR or LQ factorization to solve a overdetermined or underdetermined linear system with full rank matrix.
FORTRAN 77:
call sgels(trans, m, n, nrhs, a, lda, b, ldb, work, lwork, info)
call dgels(trans, m, n, nrhs, a, lda, b, ldb, work, lwork, info)
call cgels(trans, m, n, nrhs, a, lda, b, ldb, work, lwork, info)
call zgels(trans, m, n, nrhs, a, lda, b, ldb, work, lwork, info)
Fortran 95:
call gels(a, b [,trans] [,info])
C:
lapack_int LAPACKE_<?>gels( int matrix_order, char trans, lapack_int m, lapack_int n, lapack_int nrhs, <datatype>* a, lapack_int lda, <datatype>* b, lapack_int ldb );
The FORTRAN 77 interfaces are specified in the mkl_lapack.fi and mkl_lapack.h include files, the Fortran 95 interfaces are specified in the lapack.f90 include file, and the C interfaces are specified in the mkl_lapacke.h include file.
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 trans = 'N' and m ≥ n: find the least squares solution of an overdetermined system, that is, solve the least squares problem
minimize ||b - A*x||2
2. If trans = 'N' and m < n: find the minimum norm solution of an underdetermined system A*X = B.
3. If trans = 'T' or 'C' and m ≥ n: find the minimum norm solution of an undetermined system AH*X = B.
4. If trans = 'T' or 'C' and m < n: find the least squares solution of an overdetermined system, that is, solve the least squares problem
minimize ||b - AH*x||2
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-nrh solution matrix X.
The data types are given for the Fortran interface. A <datatype> placeholder, if present, is used for the C interface data types in the C interface section above. See C Interface Conventions for the C interface principal conventions and type definitions.
CHARACTER*1. Must be 'N', 'T', or 'C'.
If trans = 'N', the linear system involves matrix A;
If trans = 'T', the linear system involves the transposed matrix AT (for real flavors only);
If trans = 'C', the linear system involves the conjugate-transposed matrix AH (for complex flavors only).
INTEGER. The number of rows of the matrix A (m ≥ 0).
INTEGER. The number of columns of the matrix A
(n ≥ 0).
INTEGER. The number of right-hand sides; the number of columns in B (nrhs ≥ 0).
REAL for sgels
DOUBLE PRECISION for dgels
COMPLEX for cgels
DOUBLE COMPLEX for zgels.
Arrays:
a(lda,*) contains the m-by-n matrix A.
The second dimension of a must be at least max(1, n).
b(ldb,*) contains 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' or 'C'.
The second dimension of b must be at least max(1, nrhs).
work is a workspace array, its dimension max(1, lwork).
INTEGER. The leading dimension of a; at least max(1, m).
INTEGER. The leading dimension of b; must be at least max(1, m, n).
INTEGER. The size of the work array; must be at least min (m, n)+max(1, m, n, nrhs).
If lwork = -1, then a workspace query is assumed; the routine only calculates the optimal size of the work array, returns this value as the first entry of the work array, and no error message related to lwork is issued by xerbla.
See Application Notes for the suggested value of lwork.
On exit, overwritten by the factorization data as follows:
if m ≥ n, array a contains the details of the QR factorization of the matrix A as returned by ?geqrf;
if m < n, array a contains the details of the LQ factorization of the matrix A as returned by ?gelqf.
If info = 0, b 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 modulus 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' or 'C' and m ≥ n, rows 1 to m of b contain the minimum norm solution vectors; if trans = 'T' or 'C' 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 modulus of elements m+1 to n in that column.
If info = 0, on exit work(1) contains the minimum value of lwork required for optimum performance. Use this lwork for subsequent runs.
INTEGER.
If info = 0, the execution is successful.
If info = -i, the 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.
Routines in Fortran 95 interface have fewer arguments in the calling sequence than their FORTRAN 77 counterparts. For general conventions applied to skip redundant or restorable arguments, see Fortran 95 Interface Conventions.
Specific details for the routine gels interface are the following:
Holds the matrix A of size (m,n).
Holds the matrix of size max(m,n)-by-nrhs.
If trans = 'N', then, on entry, the size of b is m-by-nrhs,
If trans = 'T', then, on entry, the size of b is n-by-nrhs,
Must be 'N' or 'T'. The default value is 'N'.
For better performance, try using lwork = min (m, n)+max(1, m, n, nrhs)*blocksize, where blocksize is a machine-dependent value (typically, 16 to 64) required for optimum performance of the blocked algorithm.
If you are in doubt how much workspace to supply, use a generous value of lwork for the first run or set lwork = -1.
If you choose the first option and set any of admissible lwork sizes, which is no less than the minimal value described, the routine completes the task, though probably not so fast as with a recommended workspace, and provides the recommended workspace in the first element of the corresponding array work on exit. Use this value (work(1)) for subsequent runs.
If you set lwork = -1, the routine returns immediately and provides the recommended workspace in the first element of the corresponding array (work). This operation is called a workspace query.
Note that if you set lwork to less than the minimal required value and not -1, the routine returns immediately with an error exit and does not provide any information on the recommended workspace.
Copyright © 1994 - 2011, Intel Corporation. All rights reserved.