Matrix class and inversion routine.