Вы можете использовать линейную часть алгебры Numpy:
import numpy as np
A = np.array(([1,1],[5,-1]))
# Calculating inverse of A
B = np.linalg.inv(A)
# array([[ 0.16666667, 0.16666667],
# [ 0.83333333, -0.16666667]])
# Calculating matrix multiplication of B and A: Expecting Identical Matrix
np.matmul(B,A)
# Very close to 0 and 1
# array([[ 1.00000000e+00, 2.77555756e-17],
# [-5.55111512e-17, 1.00000000e+00]])
# Converting to integer
np.int32( np.matmul(B,A) )
# array([[1, 0],
# [0, 1]], dtype=int32)