finish inverse matrix function