Implementation of the inverse of a matrix with a result that is cached