Implemented caching of an invertable matrix