Fast computing of a matrix power for large integer values in C++
Since your matrices are small $(50 \times 50)$, you  can probably just compute $M^t$ through repeated exponentiation where the exponents are powers of $2$.
Write $t$ in binary so that  $t = 2^{k_1} + 2^{k_2} + \dots + 2^{k_\ell}$.
Then $M^t = \prod_{i=1}^\ell M^{2^{k_i}}$. Moreover, for $k_i \ge 1$  you have $M^{2^{k_i}} = \left( M^{2^{k_i - 1}} \right)^2$, so you need at most $O(\log t)$ matrix multiplications.
Here is a pseudocode where &quot;&amp;&quot; denotes &quot;bitwise and&quot; and &quot;~&quot; denotes &quot;bitwise not&quot;:
Power(M, t):
  if(t &amp; 1):        //Handle odd values of t (this saves a multiplication later)
     R = M;
     t = t &amp; ~1;    //Clear the least significant bit of t
  else:
     R = I;

  i=1;
  B=M;                //B will always be M^i, where i is a power of 2
  while t!=0:
     i = i*2;         //Advance i to the next power of 2
     B = B*B;         //B was M^(i/2) and is now M^i

     if(t &amp; i):       //i is of the form 2^j. Is the j-th bit of t set?
        R = R*B;      //Multiply the result with B=A^i
        t = t &amp; ~i;   //Clear the j-th bit of t
  
  Return R;