c    @(#)tridp.f	1.2
c
      subroutine tridp (kstart,kstop,ising,m,mm1,a,b,c,y,twocos,d,w)
      dimension        a(m)       ,b(m)       ,c(m)       ,y(m)       ,
     1                 twocos(m)  ,d(m)       ,w(m)
c
c uro is a machine dependent constant.  it is the smallest floating
c point number such that 1 + uro is greater than 1 in the
c arithmetic of this computer.
c
      uro = 1./2.**20
  101     do 106 k=kstart,kstop
          x = -twocos(k)
          d(1) = c(1)/(b(1)+x)
          w(1) = a(1)/(b(1)+x)
          y(1) = y(1)/(b(1)+x)
          bm = b(m)
          z = c(m)
              do 103 i=2,mm1
              den = b(i)+x-a(i)*d(i-1)
              d(i) = c(i)/den
              w(i) = -a(i)*w(i-1)/den
              y(i) = (y(i)-a(i)*y(i-1))/den
              y(m) = y(m)-z*y(i-1)
              bm = bm-z*w(i-1)
  102         z = -z*d(i-1)
  103         continue
          d(mm1) = d(mm1)+w(mm1)
          z = a(m)+z
          den = bm+x-z*d(mm1)
          y(m) = y(m)-z*y(m-1)
          y(m) = y(m)/den
          y(mm1) = y(mm1)-d(mm1)*y(m)
              do 105 ip=2,mm1
              i = m-ip
  104         y(i) = y(i)-d(i)*y(i+1)-w(i)*y(m)
  105         continue
  106     continue
  107 if (ising.eq.1) return
      d(1) = c(1)/(b(1)-2.)
      w(1) = a(1)/(b(1)-2.)
      y(1) = y(1)/(b(1)-2.)
      bm = b(m)
      z = c(m)
          do 109 i=2,mm1
          den = b(i)-2.-a(i)*d(i-1)
          d(i) = c(i)/den
          w(i) = -a(i)*w(i-1)/den
          y(i) = (y(i)-a(i)*y(i-1))/den
          y(m) = y(m)-z*y(i-1)
          bm = bm-z*w(i-1)
  108     z = -z*d(i-1)
  109     continue
      d(mm1) = d(mm1)+w(mm1)
      z = a(m)+z
      den = bm-2.-z*d(mm1)
      y(m) = y(m)-z*y(m-1)
      if (abs(den).gt.20.*(m**3+m**2*abs(a(m)))*uro) go to 111
  110 y(m) = 0.
      go to 112
  111 y(m) = y(m)/den
  112 y(mm1) = y(mm1)-d(mm1)*y(m)
          do 114 ip=2,mm1
          i = m-ip
  113     y(i) = y(i)-d(i)*y(i+1)-w(i)*y(m)
  114     continue
      return
      end
