Inverse matrix algorithm implementation