*DECK CQRSL SUBROUTINE CQRSL (X, LDX, N, K, QRAUX, Y, QY, QTY, B, RSD, XB, + JOB, INFO) C***BEGIN PROLOGUE CQRSL C***PURPOSE Apply the output of CQRDC to compute coordinate transfor- C mations, projections, and least squares solutions. C***LIBRARY SLATEC (LINPACK) C***CATEGORY D9, D2C1 C***TYPE COMPLEX (SQRSL-S, DQRSL-D, CQRSL-C) C***KEYWORDS LINEAR ALGEBRA, LINPACK, MATRIX, ORTHOGONAL TRIANGULAR, C SOLVE C***AUTHOR Stewart, G. W., (U. of Maryland) C***DESCRIPTION C C CQRSL applies the output of CQRDC to compute coordinate C transformations, projections, and least squares solutions. C For K .LE. MIN(N,P), let XK be the matrix C C XK = (X(JVPT(1)),X(JVPT(2)), ... ,X(JVPT(K))) C C formed from columns JVPT(1), ... ,JVPT(K) of the original C N x P matrix X that was input to CQRDC (if no pivoting was C done, XK consists of the first K columns of X in their C original order). CQRDC produces a factored unitary matrix Q C and an upper triangular matrix R such that C C XK = Q * (R) C (0) C C This information is contained in coded form in the arrays C X and QRAUX. C C On Entry C C X COMPLEX(LDX,P). C X contains the output of CQRDC. C C LDX INTEGER. C LDX is the leading dimension of the array X. C C N INTEGER. C N is the number of rows of the matrix XK. It must C have the same value as N in CQRDC. C C K INTEGER. C K is the number of columns of the matrix XK. K C must not be greater than (N,P), where P is the C same as in the calling sequence to CQRDC. C C QRAUX COMPLEX(P). C QRAUX contains the auxiliary output from CQRDC. C C Y COMPLEX(N) C Y contains an N-vector that is to be manipulated C by CQRSL. C C JOB INTEGER. C JOB specifies what is to be computed. JOB has C the decimal expansion ABCDE, with the following C meaning. C C If A .NE. 0, compute QY. C If B,C,D, or E .NE. 0, compute QTY. C If C .NE. 0, compute B. C If D .NE. 0, compute RSD . C If E .NE. 0, compute XB. C C Note that a request to compute B, RSD, or XB C automatically triggers the computation of QTY, for C which an array must be provided in the calling C sequence. C C On Return C C QY COMPLEX(N). C QY contains Q*Y, if its computation has been C requested. C C QTY COMPLEX(N). C QTY contains CTRANS(Q)*Y, if its computation has C been requested. Here CTRANS(Q) is the conjugate C transpose of the matrix Q. C C B COMPLEX(K) C B contains the solution of the least squares problem C C minimize NORM2(Y - XK*B), C C if its computation has been requested. (Note that C if pivoting was requested in CQRDC, the J-th C component of B will be associated with column JVPT(J) C of the original matrix X that was input into CQRDC.) C C RSD COMPLEX(N). C RSD contains the least squares residual Y - XK*B, C if its computation has been requested. RSD is C also the orthogonal projection of Y onto the C orthogonal complement of the column space of XK. C C XB COMPLEX(N). C XB contains the least squares approximation XK*B, C if its computation has been requested. XB is also C the orthogonal projection of Y onto the column space C of X. C C INFO INTEGER. C INFO is zero unless the computation of B has C been requested and R is exactly singular. In C this case, INFO is the index of the first zero C diagonal element of R and B is left unaltered. C C The parameters QY, QTY, B, RSD, and XB are not referenced C if their computation is not requested and in this case C can be replaced by dummy variables in the calling program. C To save storage, the user may in some cases use the same C array for different parameters in the calling sequence. A C frequently occurring example is when one wishes to compute C any of B, RSD, or XB and does not need Y or QTY. In this C case one may identify Y, QTY, and one of B, RSD, or XB, while C providing separate arrays for anything else that is to be C computed. Thus the calling sequence C C CALL CQRSL(X,LDX,N,K,QRAUX,Y,DUM,Y,B,Y,DUM,110,INFO) C C will result in the computation of B and RSD, with RSD C overwriting Y. More generally, each item in the following C list contains groups of permissible identifications for C a single calling sequence. C C 1. (Y,QTY,B) (RSD) (XB) (QY) C C 2. (Y,QTY,RSD) (B) (XB) (QY) C C 3. (Y,QTY,XB) (B) (RSD) (QY) C C 4. (Y,QY) (QTY,B) (RSD) (XB) C C 5. (Y,QY) (QTY,RSD) (B) (XB) C C 6. (Y,QY) (QTY,XB) (B) (RSD) C C In any group the value returned in the array allocated to C the group corresponds to the last member of the group. C C***REFERENCES J. J. Dongarra, J. R. Bunch, C. B. Moler, and G. W. C Stewart, LINPACK Users' Guide, SIAM, 1979. C***ROUTINES CALLED CAXPY, CCOPY, CDOTC C***REVISION HISTORY (YYMMDD) C 780814 DATE WRITTEN C 890531 Changed all specific intrinsics to generic. (WRB) C 890831 Modified array declarations. (WRB) C 890831 REVISION DATE from Version 3.2 C 891214 Prologue converted to Version 4.0 format. (BAB) C 900326 Removed duplicate information from DESCRIPTION section. C (WRB) C 920501 Reformatted the REFERENCES section. (WRB) C***END PROLOGUE CQRSL