implemented method to cache the inverse of a matrix