Implement caching matrix inverse functionality