c****************************************************************
c
c subroutine bsolve appears as figure 14.17 in "introduction to
c computing" by dyck, v.a., lawson, j.d., and smith, j.a.,
c copyright 1979 by reston publishing company.
c
c subprogram to solve a triangular system of n equations
c in n unknowns.
c
C SLIGHTLY MODIFIED FOR UNIX f77 COMPILER, August 15,1987
C
c*****************************************************************
c
c n - the actual size of all arrays
c ndim - the variable dimension of all arrays
c t - upper triangular coefficient matrix of size nxn
c (assumed to be non-singular)
c c - right hand side of the system
c z - solution of the system of equations
c sum - temporary storage for sum of products
c
c*****************************************************************
c
subroutine bsolve(ndim,n,t,z,c)
c
integer ndim, n, i, j
real t(ndim,ndim), z(ndim), c(ndim), sum
c
c starting with z(n) = c(n)/t(n,n),
c solve for z(n-1), z(n-2), ... , z(1).
c
i = n
C
C We believe these are WHILE loops
C If you can prove otherwise, Self Paced Cntr will give you 1 quart of Ice Cream
C
1 if(i .ge. 1) then
sum = c(i)
j = i + 1
10 if(j .le. n) then
sum = sum - t(i,j)*z(j)
j = j + 1
go to 10
endif
z(i) = sum/t(i,i)
i = i - 1
go to 1
endif
return
end