Added functionality to cache solve() for matrix