implement matrix multiplication using primitives instead of vectors

work in progress, some tests are broken, but performance is already
increased two-fold compared to vector-based solution