*DECK QRSOLV SUBROUTINE QRSOLV (N, R, LDR, IPVT, DIAG, QTB, X, SIGMA, WA) C***BEGIN PROLOGUE QRSOLV C***SUBSIDIARY C***PURPOSE Subsidiary to SNLS1 and SNLS1E C***LIBRARY SLATEC C***TYPE SINGLE PRECISION (QRSOLV-S, DQRSLV-D) C***AUTHOR (UNKNOWN) C***DESCRIPTION C C Given an M by N matrix A, an N by N diagonal matrix D, C and an M-vector B, the problem is to determine an X which C solves the system C C A*X = B , D*X = 0 , C C in the least squares sense. C C This subroutine completes the solution of the problem C if it is provided with the necessary information from the C QR factorization, with column pivoting, of A. That is, if C A*P = Q*R, where P is a permutation matrix, Q has orthogonal C columns, and R is an upper triangular matrix with diagonal C elements of nonincreasing magnitude, then QRSOLV expects C the full upper triangle of R, the permutation matrix P, C and the first N components of (Q TRANSPOSE)*B. The system C A*X = B, D*X = 0, is then equivalent to C C T T C R*Z = Q *B , P *D*P*Z = 0 , C C where X = P*Z. If this system does not have full rank, C then a least squares solution is obtained. On output QRSOLV C also provides an upper triangular matrix S such that C C T T T C P *(A *A + D*D)*P = S *S . C C S is computed within QRSOLV and may be of separate interest. C C The subroutine statement is C C SUBROUTINE QRSOLV(N,R,LDR,IPVT,DIAG,QTB,X,SIGMA,WA) C C where C C N is a positive integer input variable set to the order of R. C C R is an N by N array. On input the full upper triangle C must contain the full upper triangle of the matrix R. C On output the full upper triangle is unaltered, and the C strict lower triangle contains the strict upper triangle C (transposed) of the upper triangular matrix S. C C LDR is a positive integer input variable not less than N C which specifies the leading dimension of the array R. C C IPVT is an integer input array of length N which defines the C permutation matrix P such that A*P = Q*R. Column J of P C is column IPVT(J) of the identity matrix. C C DIAG is an input array of length N which must contain the C diagonal elements of the matrix D. C C QTB is an input array of length N which must contain the first C N elements of the vector (Q TRANSPOSE)*B. C C X is an output array of length N which contains the least C squares solution of the system A*X = B, D*X = 0. C C SIGMA is an output array of length N which contains the C diagonal elements of the upper triangular matrix S. C C WA is a work array of length N. C C***SEE ALSO SNLS1, SNLS1E C***ROUTINES CALLED (NONE) C***REVISION HISTORY (YYMMDD) C 800301 DATE WRITTEN C 890831 Modified array declarations. (WRB) C 891214 Prologue converted to Version 4.0 format. (BAB) C 900326 Removed duplicate information from DESCRIPTION section. C (WRB) C 900328 Added TYPE section. (WRB) C***END PROLOGUE QRSOLV