Is it possible to use numpy\'s linalg.matrix_power with a modulo so the elements don\'t grow larger than a certain value?
What's wrong with the obvious approach?
E.g.
import numpy as np x = np.arange(100).reshape(10,10) y = np.linalg.matrix_power(x, 2) % 50