Added functionality to cache the inverse of the matrix