Implement caching solve for matrices