rocket-lang icon indicating copy to clipboard operation
rocket-lang copied to clipboard

Implement matrix multiplication

Open juuljuul opened this issue 3 years ago • 2 comments

Since matrix multiplication is a nice mathematical feature, I would like to see it implemented in RocketLang.

For the definition of matrix multiplications, see here: https://en.wikipedia.org/wiki/Matrix_multiplication

Condition: all entries have to be numbers (ints, doubles etc.)

Example: [[1,2],[3,4]]*[[8,7],[6,5]] = [ (1*8+2*6), (1*7+2*5)], [(3*8+4*6) ,(3*7+4*5) ] = [[20 , 17 ] , [48, 41]]

More general: If size(A) =[m,n] and size(B) = [n,p] (the n is important!), then C=A*B with

C[i,j]=0
for k in [1, n]:
C[i,j]+= A[i,k]*B[k,j]

I am open to write the test cases :)

juuljuul avatar Jan 27 '22 21:01 juuljuul

Thanks for the input, indeed test cases as an example would be great!

Flipez avatar Feb 06 '22 18:02 Flipez

The testcases were added to the branch https://github.com/Flipez/rocket-lang/tree/feat/matrix_multiplication.

juuljuul avatar Mar 15 '22 20:03 juuljuul