Electronic structure optimization in plane-wave-based density functional calculations by direct inversion in the iterative subspace