Updated for matrix inverse with cached result