Changed function for matrix inversion cache