Implements the invert matrix through a cache object