RE: permanent of square matrix
Translated above to HP71B BASIC
Code:
10 DESTROY ALL @ OPTION BASE 1 @ INPUT "N? ";N
20 DIM M(N,N),D(N),F(N),V(N) @ MAT INPUT M @ T0=TIME
30 MAT D=(2) @ MAT V=CSUM(M) @ P=1 @ S=1
40 FOR I=1 TO N @ F(I)=I @ P=P*V(I) @ NEXT I
50 WHILE F(1)<N @ I=F(1) @ T=1
60 FOR J=1 TO N @ V(J)=V(J)-D(I)*M(I,J) @ T=T*V(J) @ NEXT J
70 P=P-S*T @ S=-S @ D(I)=-D(I) @ F(1)=1 @ F(I)=F(I+1) @ F(I+1)=I+1
80 END WHILE
90 P=P/2^(N-1) @ DISP "P=";P,TIME-T0
OP 9×9 random matrix example
Code:
N? 9
M(1,1)? 86, -97, -82, 7, -27, 26, -89, 63, -49
M(2,1)? -86, -64, -30, 70, 22, 42, 56, -9, -13
M(3,1)? 46, 24, 49, -6, 0, 81, 18, -49, -33
M(4,1)? -70, 8, 63, -64, 2, 62, -37, -80, -23
M(5,1)? 65, -85, 28, -44, -22, 93, 91, 31, -21
M(6,1)? 88, 76, -66, 66, 5, -23, 79, -88, 9
M(7,1)? 6, -69, -8, 31, 89, 2, 97, -92, 80
M(8,1)? -24, -17, 41, 64, -49, 0, 89, 18, -51
M(9,1)? -42, -65, 22, -94, 76, -10, 16, -63, 39
P=-3.50063186806E18 3.12
Emulator running at 40x --> Physical HP71B take 3.12*40 ≈ 125 s ≈ 2 min
|