memoized matrix multiplication
Updated to work for any Finite type