Inverse matrix modification lemma and Thevenin theorem for compensated network solutions