R functions to invert a matrix or retrieve its inverse from the cache