implementing matrix inverse caching