Developer Reference for Intel® oneAPI Math Kernel Library for Fortran

ID 766686
Date 7/13/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

?getsls

Uses QR or LQ factorization to solve an overdetermined or underdetermined linear system with full rank matrix, with best performance for tall and skinny matrices.

call sgetsls(trans, m, n, nrhs, a, lda, b, ldb, work, lwork, info)

call dgetsls(trans, m, n, nrhs, a, lda, b, ldb, work, lwork, info)

call cgetsls(trans, m, n, nrhs, a, lda, b, ldb, work, lwork, info)

call zgetsls(trans, m, n, nrhs, a, lda, b, ldb, work, lwork, info)

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 ?geqr or ?gelq factorization of A. It is assumed that A has full rank.

The following options are provided:

1. If trans = 'N' and mn: 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 mn: 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 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 AT or AH, B isn-by-nrhs and X is m-by-nrhs.

Input Parameters

trans

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).

m

INTEGER. The number of rows of the matrix A. m 0.

n

INTEGER. The number of columns of the matrix A. n 0.

nrhs

INTEGER. The number of right-hand sides; the number of columns in B (nrhs 0).

a

REAL for sgetsls

DOUBLE PRECISION for dgetsls

COMPLEX for cgetsls

COMPLEX*16 for zgetsls

Array a(lda,*) contains the m-by-n matrix A.

The second dimension of a must be at least max(1, n).

lda

INTEGER. The leading dimension of the array a. ldamax(1,m).

b

REAL for sgetsls

DOUBLE PRECISION for dgetsls

COMPLEX for cgetsls

COMPLEX*16 for zgetsls

Array b(ldb,*) contains the matrix B of right hand side vectors.

The second dimension of b must be at least max(1, nrhs).

ldb

INTEGER. The leading dimension of the array b. ldbmax(1,m,n).

lwork

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.

Output Parameters

a

On exit, overwritten by the factorization data as follows:

if mn, array a contains the details of the QR factorization of the matrix A as returned by ?geqr;

if m < n, array a contains the details of the LQ factorization of the matrix A as returned by ?gelq.

b

If info = 0, b overwritten by the solution vectors, stored columnwise:

if trans = 'N' and mn, 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 mn, 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.

work(1)

If info = 0, on exit work(1) contains the minimum value of lwork required for optimum performance. Use this lwork for subsequent runs.

info

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.