Created a pair of functions that invert a matrix in a memory-efficient way.