春
春风江南
Unregistered / Unconfirmed
GUEST, unregistred user!
有一段fortran子程序,是求行列式的值的。我不懂fortran,但只能找到fortran的源程序。谁帮忙给翻译一下成pascal?要求M维数组A的初值从[0,0]开始,所以可能要改一点程序吧。
FUNCTION DET (M,A)
DIMENSION A(M,M)
IS=1
PR=1.0
M2=M-1
DO 5 K=1,M2
PM=0
K1=K+1
DO 10 I=K,M //是不是这儿要动改动?
DO 10 J=K,M
PV=A(I,J)
IF(ABS(PV).LT.ABS(PM)) GOTO 10
PM=PV
I0=I
J0=J
10 CONTINUE
IF (PM.EQ.0) GOTO 50
IF (I0.EQ.K) GOTO 25
IS=-IS
DO 20 J=K,M
T=A(I0,J)
A(I0,J)=A(K,J)
20 A(K,J)=T
25 IF(J0.EQ.K) GOTO 35
IS=-IS
DO 30 I=K,M
T=A(I,J0)
A(I,J0)=A(I,K)
30 A(I,K)=T
35 PR=PR*PM
PM=-1/PM
DO 40 I=K1,M
Q=A(I,K)*PM
DO 40 J=K1,M
40 A(I,J)=A(I,J)+Q*A(K,J)
5 CONTINUE
DET=IS*PR*A(M,M)
GOTO 60
50 DET=0
60 RETURN
END
FUNCTION DET (M,A)
DIMENSION A(M,M)
IS=1
PR=1.0
M2=M-1
DO 5 K=1,M2
PM=0
K1=K+1
DO 10 I=K,M //是不是这儿要动改动?
DO 10 J=K,M
PV=A(I,J)
IF(ABS(PV).LT.ABS(PM)) GOTO 10
PM=PV
I0=I
J0=J
10 CONTINUE
IF (PM.EQ.0) GOTO 50
IF (I0.EQ.K) GOTO 25
IS=-IS
DO 20 J=K,M
T=A(I0,J)
A(I0,J)=A(K,J)
20 A(K,J)=T
25 IF(J0.EQ.K) GOTO 35
IS=-IS
DO 30 I=K,M
T=A(I,J0)
A(I,J0)=A(I,K)
30 A(I,K)=T
35 PR=PR*PM
PM=-1/PM
DO 40 I=K1,M
Q=A(I,K)*PM
DO 40 J=K1,M
40 A(I,J)=A(I,J)+Q*A(K,J)
5 CONTINUE
DET=IS*PR*A(M,M)
GOTO 60
50 DET=0
60 RETURN
END