Rev 76639 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
cc dqrdc uses householder transformations to compute the qrc factorization of an n by p matrix x. column pivotingc based on the 2-norms of the reduced columns may bec performed at the users option.cc on entrycc x double precision(ldx,p), where ldx .ge. n.c x contains the matrix whose decomposition is to bec computed.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 x.cc p integer.c p is the number of columns of the matrix x.cc jpvt integer(p).c jpvt contains integers that control the selectionc of the pivot columns. the k-th column x(k) of xc is placed in one of three classes according to thec value of jpvt(k).cc if jpvt(k) .gt. 0, then x(k) is an initialc column.cc if jpvt(k) .eq. 0, then x(k) is a free column.cc if jpvt(k) .lt. 0, then x(k) is a final column.cc before the decomposition is computed, initial columnsc are moved to the beginning of the array x and finalc columns to the end. both initial and final columnsc are frozen in place during the computation and onlyc free columns are moved. at the k-th stage of thec reduction, if x(k) is occupied by a free columnc it is interchanged with the free column of largestc reduced norm. jpvt is not referenced ifc job .eq. 0.cc work double precision(p).c work is a work array. work is not referenced ifc job .eq. 0.cc job integer.c job is an integer that initiates column pivoting.c if job .eq. 0, no pivoting is done.c if job .ne. 0, pivoting is done.cc on returncc x x contains in its upper triangle the upperc triangular matrix r of the qr factorization.c below its diagonal x contains information fromc which the orthogonal part of the decompositionc can be recovered. note that if pivoting hasc been requested, the decomposition is not thatc of the original matrix x but that of xc with its columns permuted as described by jpvt.cc qraux double precision(p).c qraux contains further information required to recoverc the orthogonal part of the decomposition.cc jpvt jpvt(k) contains the index of the column of thec original matrix that has been interchanged intoc the k-th column, if pivoting was requested.cc linpack. this version dated 08/14/78 .c g.w. stewart, university of maryland, argonne national lab.cc dqrdc uses the following functions and subprograms.cc blas daxpy,ddot,dscal,dswap,dnrm2c fortran dabs,dmax1,min0,dsqrtcsubroutine dqrdc(x,ldx,n,p,qraux,jpvt,work,job)integer ldx,n,p,jobinteger jpvt(p)double precision x(ldx,p),qraux(p),work(p)cc internal variablescinteger j,jp,jj, l,lp1,lup,maxj,pl,pudouble precision maxnrm,dnrm2,ttdouble precision ddot,nrmxl,tlogical negj,swapjccpl = 1pu = 0if (job .eq. 0) go to 60cc pivoting has been requested. rearrange the columnsc according to jpvt.cdo 20 j = 1, pswapj = jpvt(j) .gt. 0negj = jpvt(j) .lt. 0jpvt(j) = jif (negj) jpvt(j) = -jif (.not.swapj) go to 10if (j .ne. pl) call dswap(n,x(1,pl),1,x(1,j),1)jpvt(j) = jpvt(pl)jpvt(pl) = jpl = pl + 110 continue20 continuepu = pdo 50 jj = 1, pj = p - jj + 1if (jpvt(j) .ge. 0) go to 40jpvt(j) = -jpvt(j)if (j .eq. pu) go to 30call dswap(n,x(1,pu),1,x(1,j),1)jp = jpvt(pu)jpvt(pu) = jpvt(j)jpvt(j) = jp30 continuepu = pu - 140 continue50 continue60 continuecc compute the norms of the free columns.cif (pu .lt. pl) go to 80do 70 j = pl, puqraux(j) = dnrm2(n,x(1,j),1)work(j) = qraux(j)70 continue80 continuecc perform the householder reduction of x.clup = min0(n,p)do 200 l = 1, lupif (l .lt. pl .or. l .ge. pu) go to 120cc locate the column of largest norm and bring itc into the pivot position.cmaxnrm = 0.0d0maxj = ldo 100 j = l, puif (qraux(j) .le. maxnrm) go to 90maxnrm = qraux(j)maxj = j90 continue100 continueif (maxj .eq. l) go to 110call dswap(n,x(1,l),1,x(1,maxj),1)qraux(maxj) = qraux(l)work(maxj) = work(l)jp = jpvt(maxj)jpvt(maxj) = jpvt(l)jpvt(l) = jp110 continue120 continueqraux(l) = 0.0d0if (l .eq. n) go to 190cc compute the householder transformation for column l.cnrmxl = dnrm2(n-l+1,x(l,l),1)if (nrmxl .eq. 0.0d0) go to 180if (x(l,l) .ne. 0.0d0) nrmxl = dsign(nrmxl,x(l,l))call dscal(n-l+1,1.0d0/nrmxl,x(l,l),1)x(l,l) = 1.0d0 + x(l,l)cc apply the transformation to the remaining columns,c updating the norms.clp1 = l + 1if (p .lt. lp1) go to 170do 160 j = lp1, pt = -ddot(n-l+1,x(l,l),1,x(l,j),1)/x(l,l)call daxpy(n-l+1,t,x(l,l),1,x(l,j),1)if (j .lt. pl .or. j .gt. pu) go to 150if (qraux(j) .eq. 0.0d0) go to 150tt = 1.0d0 - (dabs(x(l,j))/qraux(j))**2tt = dmax1(tt,0.0d0)t = tttt = 1.0d0 + 0.05d0*tt*(qraux(j)/work(j))**2if (tt .eq. 1.0d0) go to 130qraux(j) = qraux(j)*dsqrt(t)go to 140130 continueqraux(j) = dnrm2(n-l,x(l+1,j),1)work(j) = qraux(j)140 continue150 continue160 continue170 continuecc save the transformation.cqraux(l) = x(l,l)x(l,l) = -nrmxl180 continue190 continue200 continuereturnend