fix bug of general matrix inversion function