Rev 12778 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
cc dqrsl applies the output of dqrdc to compute coordinatec transformations, projections, and least squares solutions.c for k .le. min(n,p), let xk be the matrixcc xk = (x(jpvt(1)),x(jpvt(2)), ... ,x(jpvt(k)))cc formed from columnns jpvt(1), ... ,jpvt(k) of the originalc n x p matrix x that was input to dqrdc (if no pivoting wasc done, xk consists of the first k columns of x in theirc original order). dqrdc produces a factored orthogonal matrix qc and an upper triangular matrix r such thatcc xk = q * (r)c (0)cc this information is contained in coded form in the arraysc x and qraux.cc on entrycc x double precision(ldx,p).c x contains the output of dqrdc.cc ldx integer.c ldx is the leading dimension of the array x.cc n integer.c n is the number of rows of the matrix xk. it mustc have the same value as n in dqrdc.cc k integer.c k is the number of columns of the matrix xk. kc must nnot be greater than min(n,p), where p is thec same as in the calling sequence to dqrdc.cc qraux double precision(p).c qraux contains the auxiliary output from dqrdc.cc y double precision(n)c y contains an n-vector that is to be manipulatedc by dqrsl.cc job integer.c job specifies what is to be computed. job hasc the decimal expansion abcde, with the followingc meaning.cc 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.cc note that a request to compute b, rsd, or xbc automatically triggers the computation of qty, forc which an array must be provided in the callingc sequence.cc on returncc qy double precision(n).c qy conntains q*y, if its computation has beenc requested.cc qty double precision(n).c qty contains trans(q)*y, if its computation hasc been requested. here trans(q) is thec transpose of the matrix q.cc b double precision(k)c b contains the solution of the least squares problemcc minimize norm2(y - xk*b),cc if its computation has been requested. (note thatc if pivoting was requested in dqrdc, the j-thc component of b will be associated with column jpvt(j)c of the original matrix x that was input into dqrdc.)cc rsd double precision(n).c rsd contains the least squares residual y - xk*b,c if its computation has been requested. rsd isc also the orthogonal projection of y onto thec orthogonal complement of the column space of xk.cc xb double precision(n).c xb contains the least squares approximation xk*b,c if its computation has been requested. xb is alsoc the orthogonal projection of y onto the column spacec of x.cc info integer.c info is zero unless the computation of b hasc been requested and r is exactly singular. inc this case, info is the index of the first zeroc diagonal element of r and b is left unaltered.cc the parameters qy, qty, b, rsd, and xb are not referencedc if their computation is not requested and in this casec can be replaced by dummy variables in the calling program.c to save storage, the user may in some cases use the samec array for different parameters in the calling sequence. ac frequently occuring example is when one wishes to computec any of b, rsd, or xb and does not need y or qty. in thisc case one may identify y, qty, and one of b, rsd, or xb, whilec providing separate arrays for anything else that is to bec computed. thus the calling sequencecc call dqrsl(x,ldx,n,k,qraux,y,dum,y,b,y,dum,110,info)cc will result in the computation of b and rsd, with rsdc overwriting y. more generally, each item in the followingc list contains groups of permissible identifications forc a single callinng sequence.cc 1. (y,qty,b) (rsd) (xb) (qy)cc 2. (y,qty,rsd) (b) (xb) (qy)cc 3. (y,qty,xb) (b) (rsd) (qy)cc 4. (y,qy) (qty,b) (rsd) (xb)cc 5. (y,qy) (qty,rsd) (b) (xb)cc 6. (y,qy) (qty,xb) (b) (rsd)cc in any group the value returned in the array allocated toc the group corresponds to the last member of the group.cc linpack. this version dated 08/14/78 .c g.w. stewart, university of maryland, argonne national lab.cc dqrsl uses the following functions and subprograms.cc BLAS daxpy,dcopy,ddotc Fortran dabs,min0,modcsubroutine dqrsl(x,ldx,n,k,qraux,y,qy,qty,b,rsd,xb,job,info)integer ldx,n,k,job,infodouble precision x(ldx,*),qraux(*),y(*),qy(*),qty(*),b(*),rsd(*),* xb(*)cc internal variablescinteger i,j,jj,ju,kp1double precision ddot,t,templogical cb,cqy,cqty,cr,cxbccc set info flag.cinfo = 0cc determine what is to be computed.ccqy = job/10000 .ne. 0cqty = mod(job,10000) .ne. 0cb = mod(job,1000)/100 .ne. 0cr = mod(job,100)/10 .ne. 0cxb = mod(job,10) .ne. 0ju = min0(k,n-1)cc special action when n=1.cif (ju .ne. 0) go to 40if (cqy) qy(1) = y(1)if (cqty) qty(1) = y(1)if (cxb) xb(1) = y(1)if (.not.cb) go to 30if (x(1,1) .ne. 0.0d0) go to 10info = 1go to 2010 continueb(1) = y(1)/x(1,1)20 continue30 continueif (cr) rsd(1) = 0.0d0go to 25040 continuecc set up to compute qy or qty.cif (cqy) call dcopy(n,y,1,qy,1)if (cqty) call dcopy(n,y,1,qty,1)if (.not.cqy) go to 70cc compute qy.cdo 60 jj = 1, juj = ju - jj + 1if (qraux(j) .eq. 0.0d0) go to 50temp = x(j,j)x(j,j) = qraux(j)t = -ddot(n-j+1,x(j,j),1,qy(j),1)/x(j,j)call daxpy(n-j+1,t,x(j,j),1,qy(j),1)x(j,j) = temp50 continue60 continue70 continueif (.not.cqty) go to 100cc compute trans(q)*y.cdo 90 j = 1, juif (qraux(j) .eq. 0.0d0) go to 80temp = x(j,j)x(j,j) = qraux(j)t = -ddot(n-j+1,x(j,j),1,qty(j),1)/x(j,j)call daxpy(n-j+1,t,x(j,j),1,qty(j),1)x(j,j) = temp80 continue90 continue100 continuecc set up to compute b, rsd, or xb.cif (cb) call dcopy(k,qty,1,b,1)kp1 = k + 1if (cxb) call dcopy(k,qty,1,xb,1)if (cr .and. k .lt. n) call dcopy(n-k,qty(kp1),1,rsd(kp1),1)if (.not.cxb .or. kp1 .gt. n) go to 120do 110 i = kp1, nxb(i) = 0.0d0110 continue120 continueif (.not.cr) go to 140do 130 i = 1, krsd(i) = 0.0d0130 continue140 continueif (.not.cb) go to 190cc compute b.cdo 170 jj = 1, kj = k - jj + 1if (x(j,j) .ne. 0.0d0) go to 150info = jc ......exitgo to 180150 continueb(j) = b(j)/x(j,j)if (j .eq. 1) go to 160t = -b(j)call daxpy(j-1,t,x(1,j),1,b,1)160 continue170 continue180 continue190 continueif (.not.cr .and. .not.cxb) go to 240cc compute rsd or xb as required.cdo 230 jj = 1, juj = ju - jj + 1if (qraux(j) .eq. 0.0d0) go to 220temp = x(j,j)x(j,j) = qraux(j)if (.not.cr) go to 200t = -ddot(n-j+1,x(j,j),1,rsd(j),1)/x(j,j)call daxpy(n-j+1,t,x(j,j),1,rsd(j),1)200 continueif (.not.cxb) go to 210t = -ddot(n-j+1,x(j,j),1,xb(j),1)/x(j,j)call daxpy(n-j+1,t,x(j,j),1,xb(j),1)210 continuex(j,j) = temp220 continue230 continue240 continue250 continuereturnend