Rev 18346 | Blame | Last modification | View Log | Download | RSS feed
subroutine dchdc(a,lda,p,work,jpvt,job,info)integer lda,p,jpvt(p),job,infodouble precision a(lda,p),work(*)cc dchdc computes the cholesky decomposition of a positive definitec matrix. a pivoting option allows the user to estimate thec condition of a positive definite matrix or determine the rankc of a positive semidefinite matrix.cc on entrycc a double precision(lda,p).c a contains the matrix whose decomposition is toc be computed. onlt the upper half of a need be stored.c the lower part of the array a is not referenced.cc lda integer.c lda is the leading dimension of the array a.cc p integer.c p is the order of the matrix.cc work double precision.c work is a work array.cc jpvt integer(p).c jpvt contains integers that control the selectionc of the pivot elements, if pivoting has been requested.c each diagonal element a(k,k)c 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 element.cc if jpvt(k) .eq. 0, then x(k) is a free element.cc if jpvt(k) .lt. 0, then x(k) is a final element.cc before the decomposition is computed, initial elementsc are moved by symmetric row and column interchanges toc the beginning of the array a and finalc elements to the end. both initial and final elementsc are frozen in place during the computation and onlyc free elements are moved. at the k-th stage of thec reduction, if a(k,k) is occupied by a free elementc it is interchanged with the largest free elementc a(l,l) with l .ge. k. jpvt 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 a a contains in its upper half the cholesky factorc of the matrix a as it has been permuted by pivoting.cc jpvt jpvt(j) contains the index of the diagonal elementc of a that was moved into the j-th position,c provided pivoting was requested.cc info contains the index of the last positive diagonalc element of the cholesky factor.cc for positive definite matrices info = p is the normal return.c for pivoting with positive semidefinite matrices info willc in general be less than p. however, info may be greater thanc the rank of a, since rounding error can cause an otherwise zeroc element to be positive. indefinite systems will always causec info to be less than p.cc linpack. this version dated 08/14/78 .c j.j. dongarra and g.w. stewart, argonne national laboratory andc university of maryland.ccc blas daxpy,dswapc fortran dsqrtcc internal variablescinteger pu,pl,plp1,j,jp,jt,k,kb,km1,kp1,l,maxldouble precision tempdouble precision maxdialogical swapk,negkcpl = 1pu = 0info = pif (job .eq. 0) go to 160cc pivoting has been requested. rearrange thec the elements according to jpvt.cdo 70 k = 1, pswapk = jpvt(k) .gt. 0negk = jpvt(k) .lt. 0jpvt(k) = kif (negk) jpvt(k) = -jpvt(k)if (.not.swapk) go to 60if (k .eq. pl) go to 50call dswap(pl-1,a(1,k),1,a(1,pl),1)temp = a(k,k)a(k,k) = a(pl,pl)a(pl,pl) = tempplp1 = pl + 1if (p .lt. plp1) go to 40do 30 j = plp1, pif (j .ge. k) go to 10temp = a(pl,j)a(pl,j) = a(j,k)a(j,k) = tempgo to 2010 continueif (j .eq. k) go to 20temp = a(k,j)a(k,j) = a(pl,j)a(pl,j) = temp20 continue30 continue40 continuejpvt(k) = jpvt(pl)jpvt(pl) = k50 continuepl = pl + 160 continue70 continuepu = pif (p .lt. pl) go to 150do 140 kb = pl, pk = p - kb + plif (jpvt(k) .ge. 0) go to 130jpvt(k) = -jpvt(k)if (pu .eq. k) go to 120call dswap(k-1,a(1,k),1,a(1,pu),1)temp = a(k,k)a(k,k) = a(pu,pu)a(pu,pu) = tempkp1 = k + 1if (p .lt. kp1) go to 110do 100 j = kp1, pif (j .ge. pu) go to 80temp = a(k,j)a(k,j) = a(j,pu)a(j,pu) = tempgo to 9080 continueif (j .eq. pu) go to 90temp = a(k,j)a(k,j) = a(pu,j)a(pu,j) = temp90 continue100 continue110 continuejt = jpvt(k)jpvt(k) = jpvt(pu)jpvt(pu) = jt120 continuepu = pu - 1130 continue140 continue150 continue160 continuedo 270 k = 1, pcc reduction loop.cmaxdia = a(k,k)kp1 = k + 1maxl = kcc determine the pivot element.cif (k .lt. pl .or. k .ge. pu) go to 190do 180 l = kp1, puif (a(l,l) .le. maxdia) go to 170maxdia = a(l,l)maxl = l170 continue180 continue190 continuecc quit if the pivot element is not positive.cif (maxdia .gt. 0.0d0) go to 200info = k - 1c ......exitgo to 280200 continueif (k .eq. maxl) go to 210cc start the pivoting and update jpvt.ckm1 = k - 1call dswap(km1,a(1,k),1,a(1,maxl),1)a(maxl,maxl) = a(k,k)a(k,k) = maxdiajp = jpvt(maxl)jpvt(maxl) = jpvt(k)jpvt(k) = jp210 continuecc reduction step. pivoting is contained across the rows.cwork(k) = dsqrt(a(k,k))a(k,k) = work(k)if (p .lt. kp1) go to 260do 250 j = kp1, pif (k .eq. maxl) go to 240if (j .ge. maxl) go to 220temp = a(k,j)a(k,j) = a(j,maxl)a(j,maxl) = tempgo to 230220 continueif (j .eq. maxl) go to 230temp = a(k,j)a(k,j) = a(maxl,j)a(maxl,j) = temp230 continue240 continuea(k,j) = a(k,j)/work(k)work(j) = a(k,j)temp = -a(k,j)call daxpy(j-k,temp,work(kp1),1,a(kp1,j),1)250 continue260 continue270 continue280 continuereturnend