Caching inverse of a matrix using lexical scoping in R