Add logic to cache an inverted matrix