R function to cache inverse of a matrix