- 积分
- 0
- 注册时间
- 2007-4-13
- 仿真币
-
- 最后登录
- 1970-1-1
|
用FORTRAN 解决线性方程组A(1,1)X(1)+A(1,2)X(2)+A(1,3)X(3)+A(1,4)X(4)+A(1,5)X(5)+A(1,6)X(6)=B(1) 这样的六个线性方程组,已知A(N,N)的各个值和B(N)的各个值。
SUBROUTINE CROUT(A,N,M)
DIMENSION A(N,M)
DO 11 I=2,N
11 A(1,I)=A(1,I)/A(1,1)
DO 3 K=2,N
DO 2 IK=K,N
DO 2 MI=2,K
2 A(IK,K)=A(IK,K)-A(IK,MI-1)*A(MI-1,K)
J1=K+1
DO 3 J=J1,N
DO 4 MJ=2,K
4 A(K,J)=A(K,J)-A(K,MJ-1)*A(MJ-1,J)
3 A(K,J)=A(K,J)/A(K,K)
I1=N+1
DO 5 I=I-1,M
5 A(1,I)=A(1,I)/A(1,1)
DO 7 JJ=I1,M
DO 7 L=2,M
DO 8 KL=2,L
8 A(L,JJ)=A(L,JJ)-A(L,KL-1)*A(KL-1,JJ)
7 A(L,JJ)=A(L,JJ)/A(L,L)
DO 10 JI=I1,M
DO 10 K1=2,N
K2=N-K1+2
DO 10 K3=K2,N
K4=N-K1+1
10 A(K4,JI)=A(K4,JI)-A(K4,K3)*A(K3,JI)
RETURN
END
DIMENSION A(6,7)
OPEN(1,FILE='CROUT.OUT',STATUS='NEW')
DATA A/1.,1.,1.,1.,1.,1.,3.54,3.46,3.76,3.76,3.66,3.53,12.53, &
11.97,14.14,14.14,13.40,12.46,0.6947,0.7781,0.2675,0.5113,0.6347, &
0.9474,189.1,188.8,189.0,188.8,189.2,189.2,35758.8,35645.4,35721.0, &
35645.4,35796.6,35796.6,62.52,60.60,62.15,60.62,61.28,65.50/
WRITE(1,5)((A(I,J),J=1,7),I=1,6)
5 FORMAT(/1X,7E12.5)
CALL CROUT(A,6,7)
WRITE(1,10)(A(I,7),I=1,6)
10 FORMAT(//1X,'b0=',E14.7,1X,'b1=',E14.7,1X,'b2=',E14.7,1x,'b3=',E14.7, &
1X,'b4=',E14.7,1X,'b5=',E14.7,1X)
STOP
END |
|