Implemented matrix inverse caching.