Caching matrix inverse