implemented matrix multiplication and exponentiation