GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing netlib.org — netlib.org c
c Numerical Analysis:
c The Mathematics of Scientific Computing
c D.R. Kincaid & E.W. Cheney
c Brooks/Cole Publ., 1990
c
c Section 4.3
c
c Example of tridiagonal system
c
c
c file: tri.f
c
parameter (n=10)
real a(n),d(n),c(n),b(n),x(n)
c
do 2 i=1,n
d(i) = 2.0
a(i) = 0.5
c(i) = 0.5
b(i) = 3.0
2 continue
b(1) = 2.5
b(n) = 2.5
c
print *
print *,' Tridiagonal system example'
print *,' Section 4.3, Kincaid-Cheney'
print *
c
call tri(n,a,d,c,b,x)
c
do 3 i=1,n
print 4,i,x(i)
3 continue
c
4 format (3x,'x(',i2,') =',e13.6)
stop
end
c
subroutine tri(n,a,d,c,b,x)
c
c tridiagonalize the matrix
c
real a(n),d(n),c(n),b(n),x(n)
real xmult
integer i
c
do 5 i = 2,n
xmult = a(i-1)/d(i-1)
d(i) = d(i) - xmult*c(i-1)
b(i) = b(i) - xmult*b(i-1)
5 continue
x(n) = b(n)/d(n)
do 6 i = n-1,1,-1
x(i) = (b(i) - c(i)*x(i+1))/d(i)
6 continue
c
return
end
|
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |