Python implementation of a matrix inversion algorithm using LU decomposition to keep integers intact