Alternative matrix inversion code