matrix inverse cache main code