adding the function to calculate a cached inversion of matrix