Spectra
SymEigsShiftSolver.h
1 // Copyright (C) 2016-2018 Yixuan Qiu <yixuan.qiu@cos.name>
2 //
3 // This Source Code Form is subject to the terms of the Mozilla
4 // Public License v. 2.0. If a copy of the MPL was not distributed
5 // with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
6 
7 #ifndef SYM_EIGS_SHIFT_SOLVER_H
8 #define SYM_EIGS_SHIFT_SOLVER_H
9 
10 #include <Eigen/Core>
11 
12 #include "SymEigsBase.h"
13 #include "Util/SelectionRule.h"
14 #include "MatOp/DenseSymShiftSolve.h"
15 
16 namespace Spectra {
17 
18 
156 template <typename Scalar = double,
157  int SelectionRule = LARGEST_MAGN,
158  typename OpType = DenseSymShiftSolve<double> >
159 class SymEigsShiftSolver: public SymEigsBase<Scalar, SelectionRule, OpType, IdentityBOp>
160 {
161 private:
162  typedef Eigen::Array<Scalar, Eigen::Dynamic, 1> Array;
163 
164  const Scalar m_sigma;
165 
166  // First transform back the Ritz values, and then sort
167  void sort_ritzpair(int sort_rule)
168  {
169  Array m_ritz_val_org = Scalar(1.0) / this->m_ritz_val.head(this->m_nev).array() + m_sigma;
170  this->m_ritz_val.head(this->m_nev) = m_ritz_val_org;
172  }
173 
174 public:
193  SymEigsShiftSolver(OpType* op, int nev, int ncv, Scalar sigma) :
194  SymEigsBase<Scalar, SelectionRule, OpType, IdentityBOp>(op, NULL, nev, ncv),
195  m_sigma(sigma)
196  {
197  this->m_op->set_shift(m_sigma);
198  }
199 };
200 
201 
202 } // namespace Spectra
203 
204 #endif // SYM_EIGS_SHIFT_SOLVER_H
SymEigsShiftSolver(OpType *op, int nev, int ncv, Scalar sigma)