Here we have my generalized implementation of exponentiation by squaring. We'll be using it for more than just matrices, so it takes in a multiplication function and multiplicative identity: this means we can use whatever objects we want, so long as we implement multiplication and there's an equivalent to 1.

Code
Output
4 ^ 3 = 64
4 x 5 = 20

Here we have my generalized implementation of exponentiation by squaring. We'll be using it for more than just matrices, so it takes in a multiplication function and multiplicative identity: this means we can use whatever objects we want, so long as we implement multiplication and there's an equivalent to 1.

Code
Output
4 ^ 3 = 64
4 x 5 = 20