Added function definition for matrix cache inversion