Trailing-Edge
-
PDP-10 Archives
-
decuslib10-01
-
43,50110/ratinv.alg
There are 2 other files named ratinv.alg in the archive. Click here to see a list.
100' NAME--RATINV
110'
120' DESCRIPTION--INVERTS MATRICES WITH RATIONAL COEFFICIENTS
130' INTERMEDIATE RESULTS ARE REDUCED TO LOWEST FORM TO AVOID
140' EXCEEDING THE PRECISION OF THE MACHINE.
150'
160' SOURCE--UNKNOWN
170'
180' INSTRUCTIONS--THE DATA IS ENTERED AS FOLLOWS:
190' 990 DATA :SIZE OF MATRIX
200' 1000 DATA :ELEMENTS OF MATRIX, IN RATIONAL FORM, (INTEGER
210' NUMERATOR, INTEGER DEDOMINATOR,COMMA), BY ROWS.
220'
230'
240' * * * * * * * * MAIN PROGRAM * * * * * * * * *
250'
260 DIM A(10,20), B(10,20)
270 READ N
280 FOR I=1 TO N
290 FOR J=1 TO N
300 READ A(I,J), B(I,J)
310 NEXT J
320 NEXT I
330 FOR I=1 TO N
340 FOR J=N+1 TO 2*N
350 LET A(I,J)=0
360 IF I<>J-N THEN 380
370 LET A(I,J)=1
380 LET B(I,J)=1
390 NEXT J
400 NEXT I
410 FOR I=1 TO N
420 FOR J=I+1 TO N
430 LET T1=A(I,I)
440 LET T2=B(I,I)
450 IF ABS(A(J,I)*T2)<=ABS(B(J,I)*T1) THEN 530
460 FOR K=1 TO 2*N
470 LET S1=A(J,K)
480 LET S2=B(J,K)
490 LET A(J,K)=A(I,K)
500 LET B(J,K)=B(I,K)
510 LET A(I,K)=S1
520 LET B(I,K)=S2
530 NEXT K
540 NEXT J
550 IF A(I,I)<>0 THEN 580
560 PRINT "DETERMINANT = 0"
570 STOP
580 FOR J=I+1 TO 2*N
590 LET R1=A(I,J)*B(I,I)
600 LET R2=B(I,J)*A(I,I)
610 GOSUB 890
620 LET A(I,J)=R1
630 LET B(I,J)=R2
640 NEXT J
650 FOR J=1 TO N
660 IF J=I THEN 740
670 FOR K=I+1 TO 2*N
680 LET R1=A(J,K)*B(J,I)*B(I,K)-B(J,K)*A(J,I)*A(I,K)
690 LET R2=B(J,K)*B(J,I)*B(I,K)
700 GOSUB 890
710 LET A(J,K)=R1
720 LET B(J,K)=R2
730 NEXT K
740 NEXT J
750 NEXT I
760 FOR I=1 TO N
770 FOR J=1 TO N
780 LET A(I,J)=A(I,N+J)
790 LET B(I,J)=B(I,N+J)
800 NEXT J
810 NEXT I
820 FOR I=1 TO N
830 FOR J=1 TO N
840 PRINT A(I,J)/B(I,J),
850 NEXT J
860 PRINT
870 NEXT I
880 STOP
890 LET P = ABS(R1)
900 LET Q = ABS(R2)
910 LET R = P - Q*INT(P/Q)
920 IF R = 0 THEN 960
930 LET P = Q
940 LET Q = R
950 GO TO 910
960 LET R1 = R1/Q
970 LET R2 = R2/Q
980 RETURN
990 DATA 5
1000 DATA 1,1,1,2,1,3,1,4,1,5
1010 DATA 1,2,1,3,1,4,1,5,1,6
1020 DATA 1,3,1,4,1,5,1,6,1,7
1030 DATA 1,4,1,5,1,6,1,7,1,8
1040 DATA 1,5,1,6,1,7,1,8,1,9
1050 END