Implement caching matrix's inverse.