excuse me for maybe misstating the question. I studied linear algebra about a year ago in university. I remember learning how to easily calculate
$$A^{-7}$$
or any larger number instead of $-7$. (or simply calculating $A^{-1}$ inverse of an $n \times n$ square matrix efficiently without really inverting it)
I learnt it in the section about diagnolizability. I think it had to do with upper and lower triangular matrices.
I didn't think I'd have to use this knowledge of linear algebra ever again, but turns out I do now because I am using a computer and need to do it efficiently, and I vaguely remember learning about this in university. Anyone know what I am talking about?
One super simple method is to use elementary row operations on the matrix $A$ to take it to the Identity (so Gaussian elimination).
At the same time you are doing this you do the same row operations to the identity matrix.
After you are done, the matrix that started out being $I$ is going to be $A^{-1}$.
Afer doing this you can exponentiate $A^{-1}$ to the desired power with binary exponentiation.