7 #ifndef SPECTRA_SYM_GEIGS_SHIFT_SOLVER_H
8 #define SPECTRA_SYM_GEIGS_SHIFT_SOLVER_H
11 #include "SymEigsBase.h"
12 #include "Util/GEigsMode.h"
13 #include "MatOp/internal/SymGEigsShiftInvertOp.h"
14 #include "MatOp/internal/SymGEigsBucklingOp.h"
15 #include "MatOp/internal/SymGEigsCayleyOp.h"
43 template <
typename OpType,
typename BOpType, GEigsMode Mode>
146 template <
typename OpType,
typename BOpType>
148 public SymEigsBase<SymGEigsShiftInvertOp<OpType, BOpType>, BOpType>
151 using Scalar =
typename OpType::Scalar;
152 using Index = Eigen::Index;
153 using Array = Eigen::Array<Scalar, Eigen::Dynamic, 1>;
155 using ModeMatOp = SymGEigsShiftInvertOp<OpType, BOpType>;
158 using Base::m_ritz_val;
160 const Scalar m_sigma;
163 static ModeMatOp set_shift_and_move(ModeMatOp&& op,
const Scalar& sigma)
166 return std::move(op);
170 void sort_ritzpair(
SortRule sort_rule)
override
174 m_ritz_val.head(m_nev).array() = Scalar(1) / m_ritz_val.head(m_nev).array() + m_sigma;
175 Base::sort_ritzpair(sort_rule);
201 Base(set_shift_and_move(ModeMatOp(op, Bop), sigma), Bop, nev, ncv),
306 template <
typename OpType,
typename BOpType>
308 public SymEigsBase<SymGEigsBucklingOp<OpType, BOpType>, BOpType>
311 using Scalar =
typename OpType::Scalar;
312 using Index = Eigen::Index;
313 using Array = Eigen::Array<Scalar, Eigen::Dynamic, 1>;
315 using ModeMatOp = SymGEigsBucklingOp<OpType, BOpType>;
318 using Base::m_ritz_val;
320 const Scalar m_sigma;
323 static ModeMatOp set_shift_and_move(ModeMatOp&& op,
const Scalar& sigma)
325 if (sigma == Scalar(0))
326 throw std::invalid_argument(
"SymGEigsShiftSolver: sigma cannot be zero in the buckling mode");
328 return std::move(op);
332 void sort_ritzpair(
SortRule sort_rule)
override
336 m_ritz_val.head(m_nev).array() = m_sigma * m_ritz_val.head(m_nev).array() /
337 (m_ritz_val.head(m_nev).array() - Scalar(1));
338 Base::sort_ritzpair(sort_rule);
364 Base(set_shift_and_move(ModeMatOp(op, Bop), sigma), Bop, nev, ncv),
398 template <
typename OpType,
typename BOpType>
400 public SymEigsBase<SymGEigsCayleyOp<OpType, BOpType>, BOpType>
403 using Scalar =
typename OpType::Scalar;
404 using Index = Eigen::Index;
405 using Array = Eigen::Array<Scalar, Eigen::Dynamic, 1>;
407 using ModeMatOp = SymGEigsCayleyOp<OpType, BOpType>;
410 using Base::m_ritz_val;
412 const Scalar m_sigma;
415 static ModeMatOp set_shift_and_move(ModeMatOp&& op,
const Scalar& sigma)
417 if (sigma == Scalar(0))
418 throw std::invalid_argument(
"SymGEigsShiftSolver: sigma cannot be zero in the Cayley mode");
420 return std::move(op);
424 void sort_ritzpair(
SortRule sort_rule)
override
428 m_ritz_val.head(m_nev).array() = m_sigma * (m_ritz_val.head(m_nev).array() + Scalar(1)) /
429 (m_ritz_val.head(m_nev).array() - Scalar(1));
430 Base::sort_ritzpair(sort_rule);
456 Base(set_shift_and_move(ModeMatOp(op, Bop), sigma), Bop, nev, ncv),
SymGEigsShiftSolver(OpType &op, BOpType &Bop, Index nev, Index ncv, const Scalar &sigma)
SymGEigsShiftSolver(OpType &op, BOpType &Bop, Index nev, Index ncv, const Scalar &sigma)
SymGEigsShiftSolver(OpType &op, BOpType &Bop, Index nev, Index ncv, const Scalar &sigma)
@ Buckling
Buckling mode for generalized eigenvalue solver.
@ Cayley
Cayley transformation mode for generalized eigenvalue solver.
@ ShiftInvert
Shift-and-invert mode for generalized eigenvalue solver.