CSUM 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=CSUM(Matrix)
110 PRINT "The sum of each column is as follows"
120 PRINT Vector(*)
130 END
140 SUB Prtmat(A(*),Lenarr,Widarr)
150! This sub prints out a matrix length of Lenarr and wide as widarr.
160! A 3x3 matrix would print like:
170! [ 1 2 3 ] Widarr = 3
180! [ 4 5 6 ]
190! [ 7 8 9 ]
200! Lenarr = 3
210 ASSIGN @Out TO CRT
220 FOR Col=1 TO Lenarr
230 OUTPUT @Out;" [";
240 FOR Row=1 TO Widarr
250 OUTPUT @Out;A(Col,Row);
260 NEXT Row
270 OUTPUT @Out;" ]"
280 NEXT Col
290 ASSIGN @Out TO *
300 SUBEND