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 basic Gaussian elimination with pivoting c c c file: pbgauss.f c parameter (n = 2) dimension a(n,n) integer p(n) data (a(1,j),j=1,n) /10.0e-8,1.0/ data (a(2,j),j=1,n) /1.0,1.0/ data (p(i),i=1,n) /2,1/ c print * print *,' Naive Gaussian elimination with pivoting' print *,' Section 4.3, Kincaid-Cheney' print * c do 4 k=1,n-1 do 3 i=k+1,n z = a(p(i),k)/a(p(k),k) a(p(i),k) = 0.0 do 2 j=k+1,n a(p(i),j) = a(p(i),j) - z*a(p(k),j) 2 continue 3 continue 4 continue c do 6 i=1,n do 5 j=1,n print 7,i,j,a(i,j) 5 continue 6 continue c 7 format (3x,'a(',i2,',',i2,') =',e13.6) stop end