Implement the caching of the inverse matrix