Added matrix inversion code.