calculating & caching inversion of a matrix