7 #ifndef SPECTRA_DAVIDSON_SYM_EIGS_SOLVER_H
8 #define SPECTRA_DAVIDSON_SYM_EIGS_SOLVER_H
12 #include "JDSymEigsBase.h"
13 #include "Util/SelectionRule.h"
30 template <
typename 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>;
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);
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();
Matrix calculate_correction_vector() const
Matrix setup_initial_search_space(SortRule selection) const