rsum Example
10 OPTION BASE 1
20 DIM Matrix(3,3)
30 DIM Vector(3)
40 DATA 1, 2, 3, 4, 5, 6, 7, 8, 9
50 RESTORE
60 READ Matrix(*)
70 CLEAR SCREEN
80 PRINT "The matrix looks like: "
90 Prtmat(Matrix(*),3,3)
100 MAT Vector=RSUM(Matrix)
110 PRINT "The RSUM vector is [";Vector(*);"]"
120 END
130 SUB Prtmat(A(*),Lenarr,Widarr)
140! This sub prints out a matrix length of Lenarr and wide as widarr.
150! A 3x3 matrix would print like:
160! [ 1 2 3 ] Widarr = 3
170! [ 4 5 6 ]
180! [ 7 8 9 ]
190! Lenarr = 3
200 ASSIGN @Out TO CRT
210 FOR Col=1 TO Lenarr
220 OUTPUT @Out;" [";
230 FOR Row=1 TO Widarr
240 OUTPUT @Out;A(Col,Row);
250 NEXT Row
260 OUTPUT @Out;" ]"
270 NEXT Col
280 ASSIGN @Out TO *
290 SUBEND