sqrsl(l) — SunSoft Performance Library
NAME
sqrsl - solve the linear system Ax = b for a general matrix A, which has been QR- factored by xQRDC, and vectors b and x.
SYNOPSIS
CALL DQRSL (DA, LDA, N, K, DQRAUX, DY, DQY, DQTY, DB, DRESID, DAB, JOB, INFO)
CALL SQRSL (SA, LDA, N, K, SQRAUX, SY, SQY, SQTY, SB, SRESID, SAB, JOB, INFO)
CALL ZQRSL (ZA, LDA, N, K, ZQRAUX, CY, CQY, ZQTY, ZB, ZRESID, ZAB, JOB, INFO)
CALL CQRSL (CA, LDA, N, K, CQRAUX, ZY, ZQY, CQTY, CB, CRESID, CAB, JOB, INFO)
ARGUMENTS
xAPart of the QR factorization of matrix A as computed by xSRDC.
LDALeading dimension of the array A as specified in a dimension
or type statement. LDA >= max(1,N).
NNumber of rows in the matrix AK where AK is described below. N >= 0.
KNumber of columns in the matrix AK where AK is described below.
K >= 0.
xQRAUXAuxiliary output from xQRDC.
xYVector to be manipulated by xQRSL.
xQYOn exit, QY contains Q ∗ Y if its computation has been requested in
JOB; QY is not referenced if its computation is not requested.
xQTYOn exit, QTY contains QT ∗ Y if its computation has been requested
in JOB; QTY is not referenced if its computation is not requested.
xBOn entry, the right-hand side vector b.
On exit, the solution vector x. B is not referenced if its computation is not requested.
xRESIDOn exit, RESID contains the least squares residual y - AK ∗ b if
its computation has been requested. RESID also is the orthogonal projection of y onto the orthogonal complement of the column space of AK. RESID is not referenced if its computation is not requested.
xABOn exit, AB contains the least squares approximation AK ∗ b if
its computation has been requested. AB is the orthogonal projection of y onto the column space of x. AB is not referenced if its computation is not requested.
JOBInteger in the form abcde; determines which operation or
operations the subroutine will perform:
a <> 0 compute QY
b, c, d, or e <> 0 compute QTY
c <> 0 compute B
d <> 0 compute RESID
e <> 0 compute AB
INFOOn exit:
INFO = 0Subroutine completed normally.
INFO ∗ 0Returns a value k if the computation of B has been requested and R is singular; the value of k is then the index of the first zero element of R. The matrix AK is constructed from the factored orthogonal matrix Q and upper triangular matrix R from xQRDC.
SAMPLE PROGRAM
PROGRAM TEST
IMPLICIT NONE
C
INTEGER IDOB, IDORSD, IDOXB, LDA, N, NCOLA, NOPIV, NROWA
PARAMETER (IDOB = 100)
PARAMETER (IDORSD = 10)
PARAMETER (IDOXB = 1)
PARAMETER (N = 3)
PARAMETER (LDA = N)
PARAMETER (NCOLA = 2)
PARAMETER (NOPIV = 0)
PARAMETER (NROWA = N)
C
DOUBLE PRECISION A(LDA,NCOLA), B(NCOLA), NULL(N), QRAUX(N)
DOUBLE PRECISION RESID(N), WORK(N), Y(N)
INTEGER ICOL, INFO, IROW, JOB, JPIVOT
C
EXTERNAL DQRDC, DQRSL
C
C Initialize the array A to store the matrix A shown below.
C Initialize the array Y to store the vector y shown below.
C
C 1 1 1
C A = 1 0 y = 0
C 0 1 -5
C
DATA A / 1.0D0, 1.0D0, 0.0D0, 1.0D0, 0.0D0, 1.0D0 /
DATA Y / 1.0D0, 0.0D0, -5.0D0 /
C
PRINT 1000
PRINT 1010, ((A(IROW,ICOL), ICOL = 1, NCOLA), IROW = 1, NROWA)
PRINT 1020
PRINT 1030, Y
JOB = NOPIV
CALL DQRDC (A, LDA, NROWA, NCOLA, QRAUX, JPIVOT, WORK, JOB)
JOB = IDOB + IDORSD + IDOXB
CALL DQRSL (A, LDA, NROWA, NCOLA, QRAUX, Y, NULL, NULL, B,
$ RESID, NULL, JOB, INFO)
IF (INFO .EQ. 0) THEN
PRINT 1040
PRINT 1050, B
PRINT 1060
PRINT 1050, RESID
ELSE
PRINT 1070
END IF
C
1000 FORMAT (1X, ’A:’)
1010 FORMAT (2(3X, F4.1))
1020 FORMAT (/1X, ’y:’)
1030 FORMAT (3X, F4.1)
1040 FORMAT (/1X, ’Least squares solution:’)
1050 FORMAT (3X, F4.1)
1060 FORMAT (/1X, ’Residual:’)
1070 FORMAT (1X, ’A is singular.’)
C
END
SAMPLE OUTPUT
A:
1.0 1.0
1.0 0.0
0.0 1.0
y:
1.0
0.0
-5.0
Least squares solution:
2.0
-3.0
Residual:
2.0
-2.0
-2.0
SunSoft, Inc. — Last change: 27 Jun 1995