31class DavidsonSymEigsSolver :
public JDSymEigsBase<DavidsonSymEigsSolver<OpType>, OpType>
34 using Index = Eigen::Index;
35 using Scalar =
typename OpType::Scalar;
36 using Matrix = Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>;
37 using Vector = Eigen::Matrix<Scalar, Eigen::Dynamic, 1>;
42 DavidsonSymEigsSolver(OpType& op, Index nev, Index nvec_init, Index nvec_max) :
43 JDSymEigsBase<DavidsonSymEigsSolver<OpType>, OpType>(op, nev, nvec_init, nvec_max)
45 m_diagonal.resize(this->m_matrix_operator.rows());
46 for (Index i = 0; i < op.rows(); i++)
48 m_diagonal(i) = op(i, i);
52 DavidsonSymEigsSolver(OpType& op, Index nev) :
53 DavidsonSymEigsSolver(op, nev, 2 * nev, 10 * nev) {}
62 std::vector<Eigen::Index> indices_sorted = argsort(selection, m_diagonal);
64 Matrix initial_basis = Matrix::Zero(this->m_matrix_operator.rows(), this->m_initial_search_space_size);
66 for (Index k = 0; k < this->m_initial_search_space_size; k++)
68 Index row = indices_sorted[k];
69 initial_basis(row, k) = 1.0;
79 const Matrix& residues = this->m_ritz_pairs.residues();
80 const Vector& eigvals = this->m_ritz_pairs.ritz_values();
81 Matrix correction = Matrix::Zero(this->m_matrix_operator.rows(), this->m_correction_size);
82 for (Index k = 0; k < this->m_correction_size; k++)
84 Vector tmp = eigvals(k) - m_diagonal.array();
85 correction.col(k) = residues.col(k).array() / tmp.array();