R functions to create a matrix and calculate the inverse in cache mode