Rev 8399 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
c A LINPACK routine updated for Fortran 90.c A version on Netlib hasc linpack. this version dated 08/14/78 .c cleve moler, university of new mexico, argonne national lab.subroutine dgedi(a,lda,n,ipvt,det,work,job)integer lda,n,ipvt(*),jobdouble precision a(lda,*),det(2),work(*)cc dgedi computes the determinant and inverse of a matrixc using the factors computed by dgeco or dgefa.cc on entrycc a double precision(lda, n)c the output from dgeco or dgefa.cc lda integerc the leading dimension of the array a .cc n integerc the order of the matrix a .cc ipvt integer(n)c the pivot vector from dgeco or dgefa.cc work double precision(n)c work vector. contents destroyed.cc job integerc = 11 both determinant and inverse.c = 01 inverse only.c = 10 determinant only.cc on returncc a inverse of original matrix if requested.c otherwise unchanged.cc det double precision(2)c determinant of original matrix if requested.c otherwise not referenced.c determinant = det(1) * 10.0**det(2)c with 1.0 .le. dabs(det(1)) .lt. 10.0c or det(1) .eq. 0.0 .cc error conditioncc a division by zero will occur if the input factor containsc a zero on the diagonal and the inverse is requested.c it will not occur if the subroutines are called correctlyc and if dgeco has set rcond .gt. 0.0 or dgefa has setc info .eq. 0 .cc linpack. this version dated 08/14/78 .c cleve moler, university of new mexico, argonne national lab.cc subroutines and functionscc blas daxpy,dscal,dswapc fortran dabs,modcc internal variablescdouble precision tdouble precision teninteger i,j,k,kb,kp1,l,nm1ccc compute determinantcif (job/10 .eq. 0) go to 70det(1) = 1.0d0det(2) = 0.0d0ten = 10.0d0do i = 1, nif (ipvt(i) .ne. i) det(1) = -det(1)det(1) = a(i,i)*det(1)c ...exitif (det(1) .eq. 0.0d0) go to 6010 if (dabs(det(1)) .ge. 1.0d0) go to 20det(1) = ten*det(1)det(2) = det(2) - 1.0d0go to 1020 continue30 if (dabs(det(1)) .lt. ten) go to 40det(1) = det(1)/tendet(2) = det(2) + 1.0d0go to 3040 continueend do60 continue70 continuecc compute inverse(u)cif (mod(job,10) .eq. 0) returndo k = 1, na(k,k) = 1.0d0/a(k,k)t = -a(k,k)call dscal(k-1,t,a(1,k),1)kp1 = k + 1if (n .lt. kp1) go to 90do j = kp1, nt = a(k,j)a(k,j) = 0.0d0call daxpy(k,t,a(1,k),1,a(1,j),1)end do90 continueend docc form inverse(u)*inverse(l)cnm1 = n - 1if (nm1 .lt. 1) go to 140do kb = 1, nm1k = n - kbkp1 = k + 1do i = kp1, nwork(i) = a(i,k)a(i,k) = 0.0d0end dodo j = kp1, nt = work(j)call daxpy(n,t,a(1,j),1,a(1,k),1)end dol = ipvt(k)if (l .ne. k) call dswap(n,a(1,k),1,a(1,l),1)end do140 continuereturnend