Matrix multiplication: Difference between revisions

Added BASIC example.
(Added D Code)
(Added BASIC example.)
Line 93:
( -0.00, -0.00, 1.00, -0.00),
( -0.00, -0.00, -0.00, 1.00));
 
=={{header|BASIC}}==
'''Compiler''': [[QuickBasic]] 4.5
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
 
=={{header|C}}==
Anonymous user