• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Row Echelon

parthosutradhor Jul 17th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. program row_echelon
2.     implicit none
3.     integer, parameter:: m=3, n=4
4.     integer:: i, j, k
5.     real:: a(m,n), t, p
6.     open(11,file="in.txt")
7.     do i=1,m
8.         read(11,*) (a(i,j), j=1,n)
9.     end do
10.     close(11)
11.
12.     do j=1,m-1
13.
14.         ! pivoting
15.         do i=j+1, m
16.             if(abs(a(i,j)) > abs(a(j,j))) then
17.                 !row interchange
18.                 do k=1,n
19.                     t=a(j,k)
20.                     a(j,k)=a(i,k)
21.                     a(i,k)=t
22.                 end do
23.             end if
24.         end do
25.
26.         if(a(j,j)==0) cycle
27.
28.         !row echelon
29.         do i=j+1, m
30.             p=a(i,j)/a(j,j)
31.             do k=j,n
32.                 a(i,k)=a(i,k)-p*a(j,k)
33.             end do
34.         end do
35.
36.     end do
37.
38.     open(12,file="out.txt")
39.     do i=1,m
40.         write(12,*) (a(i,j), j=1,n)
41.     end do
42.     close(12)
43.
44.
45. end program row_echelon
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top