Implement caching of a matrix and its computed inverse