Added caching support for matrix inverse