subroutine cgtsl(n,c,d,e,b,info)
integer n,info
complex c(1),d(1),e(1),b(1)
c
c cgtsl given a general tridiagonal matrix and a right hand
c side will find the solution.
c
c on entry
c
c n integer
c is the order of the tridiagonal matrix.
c
c c complex(n)
c is the subdiagonal of the tridiagonal matrix.
c c(2) through c(n) should contain the subdiagonal.
c on output c is destroyed.
c
c d complex(n)
c is the diagonal of the tridiagonal matrix.
c on output d is destroyed.
c
c e complex(n)
c is the superdiagonal of the tridiagonal matrix.
c e(1) through e(n-1) should contain the superdiagonal.
c on output e is destroyed.
c
c b complex(n)
c is the right hand side vector.
c
c on return
c
c b is the solution vector.
c
c info integer
c = 0 normal value.
c = k if the k-th element of the diagonal becomes
c exactly zero. the subroutine returns when
c this is detected.
c
c linpack. this version dated 08/14/78 .
c jack dongarra, argonne national laboratory.
c
c no externals
c fortran abs,aimag,real
c
c internal variables
c
integer k,kb,kp1,nm1,nm2
complex t
complex zdum
real cabs1
cabs1(zdum) = abs(real(zdum)) + abs(aimag(zdum))
c begin block permitting ...exits to 100
c
info = 0
c(1) = d(1)
nm1 = n - 1
if (nm1 .lt. 1) go to 40
d(1) = e(1)
e(1) = (0.0e0,0.0e0)
e(n) = (0.0e0,0.0e0)
c
do 30 k = 1, nm1
kp1 = k + 1
c
c find the largest of the two rows
c
if (cabs1(c(kp1)) .lt. cabs1(c(k))) go to 10
c
c interchange row
c
t = c(kp1)
c(kp1) = c(k)
c(k) = t
t = d(kp1)
d(kp1) = d(k)
d(k) = t
t = e(kp1)
e(kp1) = e(k)
e(k) = t
t = b(kp1)
b(kp1) = b(k)
b(k) = t
10 continue
c
c zero elements
c
if (cabs1(c(k)) .ne. 0.0e0) go to 20
info = k
c ............exit
go to 100
20 continue
t = -c(kp1)/c(k)
c(kp1) = d(kp1) + t*d(k)
d(kp1) = e(kp1) + t*e(k)
e(kp1) = (0.0e0,0.0e0)
b(kp1) = b(kp1) + t*b(k)
30 continue
40 continue
if (cabs1(c(n)) .ne. 0.0e0) go to 50
info = n
go to 90
50 continue
c
c back solve
c
nm2 = n - 2
b(n) = b(n)/c(n)
if (n .eq. 1) go to 80
b(nm1) = (b(nm1) - d(nm1)*b(n))/c(nm1)
if (nm2 .lt. 1) go to 70
do 60 kb = 1, nm2
k = nm2 - kb + 1
b(k) = (b(k) - d(k)*b(k+1) - e(k)*b(k+2))/c(k)
60 continue
70 continue
80 continue
90 continue
100 continue
c
return
end