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.




 
PROGRAM MAT_PROD
 
DIM A[3,1],B[1,2],ANS[3,2]
 
BEGIN
 
DATA(1,2,3,4,5,6,7,8)
DATA(1,2,3,4,5,6)
 
FOR I=0 TO 3 DO
   FOR J=0 TO 1 DO
      READ(A[I,J])
   END FOR
END FOR
 
FOR I=0 TO 1 DO
   FOR J=0 TO 2 DO
      READ(B[I,J])
   END FOR
END FOR
 
FOR I=0 TO UBOUND(ANS,1) DO
  FOR J=0 TO UBOUND(ANS,2) DO
     FOR K=0 TO UBOUND(A,2) DO
        ANS[I,J]=ANS[I,J]+(A[I,K]*B[K,J])
     END FOR
  END FOR
END FOR
! print answer
  FOR I=0 TO UBOUND(ANS,1) DO
     FOR J=0 TO UBOUND(ANS,2) DO
        PRINT(ANS[I,J],)
     END FOR
     PRINT
  END FOR
 
END PROGRAM
 