Matrix multiplication: Difference between revisions

m
→‎{{header|PureBasic}}: changed formatting
(→‎{{header|Prolog}}: Added PureBasic)
m (→‎{{header|PureBasic}}: changed formatting)
Line 1,021:
Procedure displayMatrix(Array a(2), text.s)
Protected i, j
Protected columns = ArraySize(a(), 2), Rowsrows = ArraySize(a(), 1)
PrintN(text + ": (" + Str(Rowsrows + 1) + ", " + Str(columns + 1) + ")")
For i = 0 To Rowsrows
For j = 0 To columns
Print(LSet(Str(a(i, j)), 4, " "))
Line 1,034:
 
Procedure loadMatrix(Array a(2))
Protected Rowsrows, columns, i, j
Read.i Rowsrows
Read.i columns
Dim a(Rowsrows - 1, columns - 1)
For i = 0 To Rowsrows - 1
For j = 0 To columns - 1
Read.i a(i, j)
Line 1,052:
 
If OpenConsole()
loadMatrix(a()): displayMatrix(a(), "matrix a")
loadMatrix(b()): displayMatrix(ab(), "matrix ab")
loadMatrix(b())
displayMatrix(b(), "matrix b")
If multiplyMatrix(a(), b(), c())
displayMatrix(c(), "product of a * b")
Anonymous user