Task

Multiply two matrices together.

They can be of any dimensions, so long as the number of columns of the first matrix is equal to the number of rows of the second matrix.




Assume the matrices TO be multiplied are a AND b
 IF (LEN(a,2) = LEN(b)) 'if valid dims
        n = LEN(a,2)
        m = LEN(a)
        p = LEN(b,2)
 
        DIM ans(0 TO m - 1, 0 TO p - 1)
 
        FOR i = 0 TO m - 1
                FOR j = 0 TO p - 1
                        FOR k = 0 TO n - 1
                                ans(i, j) = ans(i, j) + (a(i, k) * b(k, j))
                        NEXT k, j, i
 
        'print answer
        FOR i = 0 TO m - 1
                FOR j = 0 TO p - 1
                        PRINT ans(i, j);
                NEXT j
                PRINT
        NEXT i
 ELSE
        PRINT "invalid dimensions"
 END IF