Get rid of O(n^2) complexity when calculating multiplication results

It's possible because we now only store the upper right triangular part of the matrix