Geometry optimization by direct inversion in the iterative subspace