c
c     Second Edition
c     Numerical Analysis:
c     The Mathematics of Scientific Computing
c     D.R. Kincaid & E.W. Cheney
c     Brooks/Cole Publ., 1996
c     ISBN 0-534-33892-5
c     COPYRIGHT (c) 1996
c
c     Section 4.2
c
c     Example of Doolittle's-factorization
c
c
c     file: doolt.f
c
      parameter (n=3)
      dimension a(n,n),l(n,n),u(n,n)
      real l
      data (a(1,j),j=1,n) / 60.0,30.0,20.0/
      data (a(2,j),j=1,n) / 30.0,20.0,15.0/
      data (a(3,j),j=1,n) / 20.0,15.0,12.0/
c
      print *
      print *,' Doolittle-factorization example'
      print *,' Section 4.2, Kincaid-Cheney'
      print *
c
      do 6 k=1,n
         l(k,k) = 1.0
         do 3 j=k,n
            sum1 = a(k,j)
            do 2 m=1,k-1
               sum1 = sum1 - l(k,m)*u(m,j)
 2          continue
            u(k,j) = sum1
 3       continue
         do 5 i=k+1,n
            sum2 = a(i,k)
            do 4 m=1,k-1
               sum2 = sum2 - l(i,m)*u(m,k)
 4          continue
            l(i,k) = sum2/u(k,k)
 5       continue
 6    continue
c
      do 8 i=1,n
         do 7 j=1,i     
            print 11,i,j,l(i,j)
 7       continue
 8    continue
c
      do 10 i=1,n
         do 9 j=i,n     
            print 12,i,j,u(i,j)
 9       continue
 10   continue
c
 11   format (1x,'l(',i2,',',i2,') =',e13.6)
 12   format (1x,'u(',i2,',',i2,') =',e13.6)
      stop
      end
