Post Reply 
permanent of square matrix
01-09-2024, 09:49 PM
Post: #7
RE: permanent of square matrix
(01-04-2024 01:13 PM)Albert Chan Wrote:  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

This brings up a problem with this algorithm. The variable p is much larger than the final value, up to 3 digits larger for the sizes of matrices we are dealing with. This limits the size of the largest matrix we can use on the 71, 28 and 48 which are limited to 12-digit numbers. Valentin's program is not as fast, but it does not have this problem. Perhaps there exists a happy medium somewhere, but the math behind these algorithms is way above my head.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
permanent of square matrix - Albert Chan - 01-02-2024, 10:41 PM
RE: permanent of square matrix - John Keith - 01-09-2024 09:49 PM
RE: permanent of square matrix - Werner - 01-10-2024, 08:32 AM
RE: permanent of square matrix - Werner - 01-26-2024, 09:25 AM
RE: permanent of square matrix - Namir - 02-15-2024, 01:25 PM
RE: permanent of square matrix - Namir - 02-15-2024, 08:08 PM



User(s) browsing this thread: 8 Guest(s)