Caching matrix inverse calculations