subroutine qrsolv
given an m by n matrix a, an n by n diagonal matrix d, and an m-vector b, the problem is to determine an x which solves the system
ax = b , dx = 0 ,
in the least squares sense.
this subroutine completes the solution of the problem if it is provided with the necessary information from the qr factorization, with column pivoting, of a. that is, if ap = qr, where p is a permutation matrix, q has orthogonal columns, and r is an upper triangular matrix with diagonal elements of nonincreasing magnitude, then qrsolv expects the full upper triangle of r, the permutation matrix p, and the first n components of (q transpose)b. the system ax = b, d*x = 0, is then equivalent to
t t
rz = q *b , p *dp*z = 0 ,
where x = p*z. if this system does not have full rank, then a least squares solution is obtained. on output qrsolv also provides an upper triangular matrix s such that
t t t p (a *a + dd)*p = s *s .
s is computed within qrsolv and may be of separate interest.
the subroutine statement is
subroutine qrsolv(n,r,ldr,ipvt,diag,qtb,x,sdiag,wa)
where
is a positive integer input variable set to the order of r.
is an n by n array. on input the full upper triangle must contain the full upper triangle of the matrix r. on output the full upper triangle is unaltered, and the strict lower triangle contains the strict upper triangle (transposed) of the upper triangular matrix s.
is a positive integer input variable not less than n which specifies the leading dimension of the array r.
is an integer input array of length n which defines the permutation matrix p such that ap = qr. column j of p is column ipvt(j) of the identity matrix.
is an input array of length n which must contain the diagonal elements of the matrix d.
is an input array of length n which must contain the first n elements of the vector (q transpose)*b.
is an output array of length n which contains the least squares solution of the system ax = b, dx = 0.
is an output array of length n which contains the diagonal elements of the upper triangular matrix s.
is a work array of length n.
subprograms called
fortran-supplied ... dabs,dsqrt
argonne national laboratory. minpack project. march 1980. burton s. garbow, kenneth e. hillstrom, jorge j. more
minpack Copyright (c) Jin Yang. All Rights Reserved.