simple matrix inversion routine