Implement cached inverse matrix calculation