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.




dim a(4, 2)
a(0, 0) = 1 : a(0, 1) = 2
a(1, 0) = 3 : a(1, 1) = 4
a(2, 0) = 5 : a(2, 1) = 6
a(3, 0) = 7 : a(3, 1) = 8
dim b(2, 3)
b(0, 0) = 1 : b(0, 1) = 2 : b(0, 2) = 3
b(1, 0) = 4 : b(1, 1) = 5 : b(1, 2) = 6
dim prod(arraysize(a(),1), arraysize(b(),2))
 
if (arraysize(a(),2) = arraysize(b(),1)) then
	for i = 0 to arraysize(a(),1)
		for j = 0 to arraysize(b(),2)
			for k = 0 to arraysize(a(),2)
				prod(i, j) = prod(i, j) + (a(i, k) * b(k, j))
			next k
		next j
	next i
 
	for i = 0 to arraysize(prod(),1)-1
		for j = 0 to arraysize(prod(),2)-1
			print prod(i, j),
		next j
		print
	next i
else
	print "invalid dimensions"
end if
end