is large, dealing with spurious eigenvalues at the end is expensive. Instead, we introduce an algorithm that restarts the search space for computing eigenvalues but does not restart CG.

The proposed algorithm, eigCG, adds new functionality to CG as shown in Figure \[fig:eigCG\] in a Matlab-like format. It uses a set of $m$ vectors, $V$, to keep track of the lowest $nev$ Ritz vectors (or more accurately the $P^{-1/2}\hat U$) of the matrix $\hat A$. Initially, $V$ is composed of the normalized CG preconditioned residuals $z/\sqrt{r^Hz}$ (step 11.13), and the projection matrix $T_m = V^HAV$ is available from (\[eq:tridiagonal\]) (steps 11.1 and 11.10). When $V$ reaches $m$ vectors, we restart it exactly as we would restart an eigensolver using (\[eq:restartedV\]) with $k=nev$. The Rayleigh Ritz can be applied both on $T_m$ and $T_{m-1}$ to produce Ritz vector coefficients for the last two consecutive steps (step 11.3). We also append a zero row to $\bar Y$ (step 11.4), so that $Y$ and $\bar Y$ have the same dimension $m$. In steps 11.5, 11.6 we use the Rayleigh Ritz again to compute an orthonormal Ritz basis for the space spanned by $[Y, \bar Y]$. In step 11.7 the restarted basis $V$ and 