created two functions to cache matrix inversion results