100 REM --- TEST MATRIX INVERSION - Valentin Albillo's version for HP-71B
110 REM --- Turned to Dartmouth BASIC by A. Maschio (extended feat.)
120 REM declare and dimension matrices
130 REM
140 OPTION BASE 1
145 DIM A(4,4),B(4,4),C(4,4)
150 REM
160 REM data for original test matrix
170 REM
180 DATA 6,-2,2,-3,-1,0,-1,2,-3,1,0,-1,1,3,1,0
190 REM
200 REM data for exact inverse matrix, for testing inverse's accuracy
210 REM
220 DATA -5,-11,-7,-1,-6,-13,-8,-1,23,50,31,5,9,20,12,2
230 REM
240 REM fill up both matrices with the corresponding elements and show
250 REM
260 MAT READ A,B
265 PRINT "Original Matrix"
266 MAT PRINT A
267 PRINT "Exact inverse Matrix"
268 MAT PRINT B
270 REM
280 REM compute in place and display the inverse matrix
290 REM
300 REM ORIGINAL LINE => MAT C=IDN
301 REM ORIGINAL LINE => MAT A=SYS(A,C)
305 MAT C=INV(A)
307 PRINT "Calculated inverse matrix:"
309 MAT PRINT C
310 REM
320 REM compute and display the norm of the error matrix
330 REM
340 MAT A=C-B
341 PRINT "Error matrix"
342 MAT PRINT A
345 PRINT "Norm of Error = ";FNORM(A) ' should yield 0 (zero)
999 END

