GenEigsRealShiftSolver.h
Go to the documentation of this file.
1 // Copyright (C) 2016-2019 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 GEN_EIGS_REAL_SHIFT_SOLVER_H
8 #define GEN_EIGS_REAL_SHIFT_SOLVER_H
9 
10 #include <Eigen/Core>
11 
12 #include "GenEigsBase.h"
13 #include "Util/SelectionRule.h"
15 
16 namespace Spectra {
17 
38 template <typename Scalar = double,
39  int SelectionRule = LARGEST_MAGN,
40  typename OpType = DenseGenRealShiftSolve<double> >
41 class GenEigsRealShiftSolver : public GenEigsBase<Scalar, SelectionRule, OpType, IdentityBOp>
42 {
43 private:
45  typedef std::complex<Scalar> Complex;
47 
48  const Scalar m_sigma;
49 
50  // First transform back the Ritz values, and then sort
51  void sort_ritzpair(int sort_rule)
52  {
53  // The eigenvalues we get from the iteration is nu = 1 / (lambda - sigma)
54  // So the eigenvalues of the original problem is lambda = 1 / nu + sigma
55  ComplexArray ritz_val_org = Scalar(1.0) / this->m_ritz_val.head(this->m_nev).array() + m_sigma;
56  this->m_ritz_val.head(this->m_nev) = ritz_val_org;
58  }
59 
60 public:
79  GenEigsRealShiftSolver(OpType* op, Index nev, Index ncv, Scalar sigma) :
80  GenEigsBase<Scalar, SelectionRule, OpType, IdentityBOp>(op, NULL, nev, ncv),
81  m_sigma(sigma)
82  {
83  this->m_op->set_shift(m_sigma);
84  }
85 };
86 
87 } // namespace Spectra
88 
89 #endif // GEN_EIGS_REAL_SHIFT_SOLVER_H
SCALAR Scalar
Definition: bench_gemm.cpp:33
GenEigsRealShiftSolver(OpType *op, Index nev, Index ncv, Scalar sigma)
static const double sigma
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
#define NULL
Definition: ccolamd.c:609
virtual void sort_ritzpair(int sort_rule)
Definition: GenEigsBase.h:214
General-purpose arrays with easy API for coefficient-wise operations.
Definition: Array.h:45
Eigen::Array< Complex, Eigen::Dynamic, 1 > ComplexArray


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:42:05