implement matrix inverse caching