More generic version of Matrix Multiplication that can be transformed in javascript with emscriten
Javascript version