Purpose
=======
LA_GELS computes the minimum-norm least squares solution to one
or more real or complex linear systems of the form A*x = b, A^T*x = b
or A^H*x = b using a QR or LQ factorization of A. Matrix A is
rectangular assumed to be of full rank. The vectors b and correspon-
ding solution vectors x are the columns of matrices denoted B and X,
respectively.
==========
SUBROUTINE LA_GELS( A, B, TRANS=trans, INFO=info )
(), INTENT( INOUT ) :: A(:,:),
CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS
INTEGER, INTENT(OUT), OPTIONAL :: INFO
where
::= REAL | COMPLEX
::= KIND(1.0) | KIND(1.0D0)
::= B(:,:) | B(:)
Arguments
=========
A (input/output) REAL or COMPLEX rectangular array, shape (:,:).
On entry, the matrix A.
On exit, if size(A,1) >= size(A,2), A is overwritten by
details of its QR factorization. If size(A,1) < size(A,2), A
is overwritten by details of its LQ factorization.
B (input/output) REAL or COMPLEX array, shape (:,:) with
size(B,1) = max(size(A,1), size(A,2)) or shape (:) with
size(B) = max(size(A,1); size(A,2)).
On entry, the matrix B.
On exit, the solution matrix X. There are four cases:
1. If TRANS = 'N' and size(A,1) >= size(A,2), then rows 1
to size(A,2) of B contain, columnwise, the least squares
solution vector(s); the residual sum of squares for the
solution vector in a column of B is given by the sum of
squares of elements in rows size(A,2)+1 to size(A,1) of
that column.
2. If TRANS = 'N' and size(A,1) < size(A,2), then rows 1
to size(A,2) of B contain, columnwise, the minimum norm
solution vector(s).
3. If TRANS = 'T' or TRANS = 'C', and size(A,1)>=size(A,2),
then rows 1 to size(A,1) of B contain, columnwise, the
minimum norm solution vector(s).
4. If TRANS = 'T' or TRANS = 'C', and size(A,1) < size(A,2),
then rows 1 to size(A,1) of B contain, columnwise, the
least squares solution vector(s); the residual sum of
squares for the solution vector in a column of B is given
by the sum of squares of elements in rows size(A,1)+1 to
size(A,2) of that column.
TRANS Optional (input) CHARACTER(LEN=1).
Specifies the form of the system of equations:
= 'N': Ax = b (No transpose)
= 'T': A^T*x = b (Transpose)
= 'C': A^H*x = b (Conjugate transpose)
Default value: 'N'.
INFO Optional (output) INTEGER
= 0: successful exit.
< 0: if INFO = -i, the i-th argument had an illegal value.
If INFO is not present and an error occurs, then the program
is terminated with an error message.