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.




Procedure multiplyMatrix(Array a(2), Array b(2), Array prd(2))
  Protected ar = ArraySize(a())    ;#rows for matrix a
  Protected ac = ArraySize(a(), 2) ;#cols for matrix a
  Protected br = ArraySize(b())    ;#rows for matrix b
  Protected bc = ArraySize(b(), 2) ;#cols for matrix b
 
  If ac = br
    Dim prd(ar, bc)
 
    Protected i, j, k
    For i = 0 To ar
      For j = 0 To bc 
        For k = 0 To br ;ac
          prd(i, j) = prd(i, j) + (a(i, k) * b(k, j))
        Next
      Next
    Next
 
    ProcedureReturn #True  ;multiplication performed, product in prd()
  Else
    ProcedureReturn #False ;multiplication not performed, dimensions invalid 
  EndIf 
EndProcedure