add function code for matrix inversion