Most programming languages have a built-in implementation of exponentiation for integers and reals only.



Task

Demonstrate how to implement matrix exponentiation as an operator.




a: matrix([3, 2],
          [4, 1])$
 
a ^^ 4;
/* matrix([417, 208],
          [416, 209]) */
 
a ^^ -1;
/* matrix([-1/5, 2/5],
          [4/5, -3/5]) */