Web pdp-10.trailing-edge.com

Trailing-Edge - PDP-10 Archives - decuslib20-01 - decus/20-0020/crout1.alg
There are 2 other files named crout1.alg in the archive. Click here to see a list.
```100'  NAME--CROUT1
110'
120'  DESCRIPTION--SOLVES M SETS OF N BY N LINEAR EQUATIONS USING
130'  THE CROUT ALGORITHM WITH ROW INTERCHANGES
140'
150'  SOURCE--UNKNOWN
160'
170'  INSTRUCTIONS--THE DATA TO BE SUPPLIED START IN LINE 1040.
180'  THEY ARE THE VALUE OF N, OF M, THE COEFFICIENT MATRIX BY ROWS, AND
190'  THE RIGHT HAND SIDE OF THE MATRIX BY COLUMNS.
200'  NOTE: IN CASE OF MORE THAN 10 FOR N OR M, THE DIM STATEMENTS IN
210'  LINES 260 AND 270 SHOULD BE CHANGES.
220'
230'
240'  *  *  *  *  *  *  *  MAIN PROGRAM  *  *  *  *  *  *  *  *  *  *  *
250'
260   DIM A(10, 10)
270   DIM B(10, 10)
280  READ N, M
290  FOR I = 1 TO N
300  FOR J = 1 TO N
310  READ A(I,J)
320  NEXT J
330  NEXT I
340  FOR J = 1 TO M
350  FOR I = 1 TO N
360  READ B(I,J)
370  NEXT I
380  NEXT J
390        REM  NOW WE START THE ELIMINATIONS.
400  FOR I = 1 TO N
410        REM  HERE WE LOOK FOR THE LARGEST ELEMENT IN A COLUMN.
420  LET X = -1
430  FOR K = I TO N
440  IF ABS( A(K,I) ) <= X THEN 470
450  LET Q = K
460  LET X = ABS( A(K,I) )
470  NEXT K
480  IF X > 0 THEN 510
490  PRINT "MATRIX OF COEFFICIENTS IS SINGULAR....."
500  STOP
510          REM  HERE WE START THE INTERCHANGE, IF NEEDED.
520  IF I = Q THEN 630
530  FOR J = 1 TO N
540  LET T = A(I,J)
550  LET A(I,J) = A(Q,J)
560  LET A(Q,J) = T
570  NEXT J
580  FOR J = 1 TO M
590  LET T = B(I,J)
600  LET B(I,J) = B(Q,J)
610  LET B(Q,J) = T
620  NEXT J
630       REM NOW WE ELIMINATE ON THAT ONE ROW.......
640  FOR J = 1 TO N
650  IF I < J THEN 680
660  LET M1 = J - 1
670  GO TO 690
680  LET M1 = I - 1
690  LET S = 0
700  FOR K = 1 TO M1
710  LET S = S + A(I,K) * A(K,J)
720  NEXT K
730  LET A(I,J) = A(I,J) + S
740  IF I >= J THEN 760
750  LET A(I,J) = - A(I,J) / A(I,I)
760  NEXT J
770  NEXT I
780     REM NOW WE HAVE THE REDUCED LEFT HAND SIDE..  NOW STARTS THE RIGHT.
790  FOR J = 1 TO M
800  FOR I = 1 TO N
810  LET S = 0
820  FOR K = 1 TO I-1
830  LET S = S + A(I,K) * B(K,J)
840  NEXT K
850  LET B(I,J) = - ( B(I,J) + S ) / A (I,I)
860  NEXT I
870  FOR I = N TO 1 STEP -1
880  LET S = 0
890  FOR K = I + 1 TO N
900  LET S = S + A(I,K) * B(K,J)
910  NEXT K
920  LET B(I,J) = -B(I,J) + S
930  NEXT I
940  NEXT J
950       REM NOW WE START THE PRINTOUT.....
960  FOR J = 1 TO M
970  PRINT
980  PRINT "ANSWER SET  ";J
990  FOR I = 1 TO N
1000  PRINT B(I,J),
1010  NEXT I
1020  NEXT J
1030  STOP
1040 DATA
1100 END
```
```
```