math/matrix: implement inversion