Cache function for inverse matrix