Caching the invert of a matrix problem