SymGEigsSolver.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 SYM_GEIGS_SOLVER_H
8 #define SYM_GEIGS_SOLVER_H
9 
10 #include "SymEigsBase.h"
11 #include "Util/GEigsMode.h"
14 
15 namespace Spectra {
16 
22 
42 
43 // Empty class template
44 template <typename Scalar,
45  int SelectionRule,
46  typename OpType,
47  typename BOpType,
48  int GEigsMode>
50 {};
51 
158 
159 // Partial specialization for GEigsMode = GEIGS_CHOLESKY
160 template <typename Scalar,
161  int SelectionRule,
162  typename OpType,
163  typename BOpType>
164 class SymGEigsSolver<Scalar, SelectionRule, OpType, BOpType, GEIGS_CHOLESKY> :
165  public SymEigsBase<Scalar, SelectionRule, SymGEigsCholeskyOp<Scalar, OpType, BOpType>, IdentityBOp>
166 {
167 private:
171 
172  BOpType* m_Bop;
173 
174 public:
200  SymGEigsSolver(OpType* op, BOpType* Bop, Index nev, Index ncv) :
201  SymEigsBase<Scalar, SelectionRule, SymGEigsCholeskyOp<Scalar, OpType, BOpType>, IdentityBOp>(
202  new SymGEigsCholeskyOp<Scalar, OpType, BOpType>(*op, *Bop), NULL, nev, ncv),
203  m_Bop(Bop)
204  {}
205 
207 
208  ~SymGEigsSolver()
209  {
210  // m_op contains the constructed SymGEigsCholeskyOp object
211  delete this->m_op;
212  }
213 
214  Matrix eigenvectors(Index nvec) const
215  {
216  Matrix res = SymEigsBase<Scalar, SelectionRule, SymGEigsCholeskyOp<Scalar, OpType, BOpType>, IdentityBOp>::eigenvectors(nvec);
217  Vector tmp(res.rows());
218  const Index nconv = res.cols();
219  for (Index i = 0; i < nconv; i++)
220  {
221  m_Bop->upper_triangular_solve(&res(0, i), tmp.data());
222  res.col(i).noalias() = tmp;
223  }
224 
225  return res;
226  }
227 
228  Matrix eigenvectors() const
229  {
231  }
232 
234 };
235 
274 
275 // Partial specialization for GEigsMode = GEIGS_REGULAR_INVERSE
276 template <typename Scalar,
277  int SelectionRule,
278  typename OpType,
279  typename BOpType>
280 class SymGEigsSolver<Scalar, SelectionRule, OpType, BOpType, GEIGS_REGULAR_INVERSE> :
281  public SymEigsBase<Scalar, SelectionRule, SymGEigsRegInvOp<Scalar, OpType, BOpType>, BOpType>
282 {
283 private:
285 
286 public:
310  SymGEigsSolver(OpType* op, BOpType* Bop, Index nev, Index ncv) :
311  SymEigsBase<Scalar, SelectionRule, SymGEigsRegInvOp<Scalar, OpType, BOpType>, BOpType>(
312  new SymGEigsRegInvOp<Scalar, OpType, BOpType>(*op, *Bop), Bop, nev, ncv)
313  {}
314 
316  ~SymGEigsSolver()
317  {
318  // m_op contains the constructed SymGEigsRegInvOp object
319  delete this->m_op;
320  }
322 };
323 
324 } // namespace Spectra
325 
326 #endif // SYM_GEIGS_SOLVER_H
Spectra::SymGEigsSolver< Scalar, SelectionRule, OpType, BOpType, GEIGS_REGULAR_INVERSE >::Index
Eigen::Index Index
Definition: SymGEigsSolver.h:284
Spectra::GEIGS_REGULAR_INVERSE
@ GEIGS_REGULAR_INVERSE
Regular inverse mode for generalized eigenvalue solver.
Definition: GEigsMode.h:21
Spectra::SymGEigsSolver< Scalar, SelectionRule, OpType, BOpType, GEIGS_CHOLESKY >::Vector
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
Definition: SymGEigsSolver.h:170
SymEigsBase.h
Spectra::SymEigsBase
Definition: SymEigsBase.h:44
Spectra::SymGEigsSolver< Scalar, SelectionRule, OpType, BOpType, GEIGS_REGULAR_INVERSE >::SymGEigsSolver
SymGEigsSolver(OpType *op, BOpType *Bop, Index nev, Index ncv)
Definition: SymGEigsSolver.h:310
res
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Definition: PartialRedux_count.cpp:3
Spectra::SymGEigsSolver
Definition: SymGEigsSolver.h:49
GEigsMode.h
Spectra::IdentityBOp
Definition: ArnoldiOp.h:90
Spectra::SymGEigsSolver< Scalar, SelectionRule, OpType, BOpType, GEIGS_CHOLESKY >::Matrix
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > Matrix
Definition: SymGEigsSolver.h:169
ceres::Matrix
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > Matrix
Definition: gtsam/3rdparty/ceres/eigen.h:42
Spectra::SymEigsBase< Scalar, SelectionRule, SymGEigsCholeskyOp< Scalar, OpType, BOpType >, IdentityBOp >::eigenvectors
virtual Matrix eigenvectors() const
Definition: SymEigsBase.h:440
Spectra::SymGEigsSolver< Scalar, SelectionRule, OpType, BOpType, GEIGS_CHOLESKY >::SymGEigsSolver
SymGEigsSolver(OpType *op, BOpType *Bop, Index nev, Index ncv)
Definition: SymGEigsSolver.h:200
Spectra::SymGEigsSolver< Scalar, SelectionRule, OpType, BOpType, GEIGS_CHOLESKY >::m_Bop
BOpType * m_Bop
Definition: SymGEigsSolver.h:172
SymGEigsRegInvOp.h
Spectra::SymGEigsSolver< Scalar, SelectionRule, OpType, BOpType, GEIGS_CHOLESKY >::Index
Eigen::Index Index
Definition: SymGEigsSolver.h:168
Spectra::SymGEigsCholeskyOp
Definition: SymGEigsCholeskyOp.h:27
Spectra::SymGEigsRegInvOp
Definition: SymGEigsRegInvOp.h:25
Spectra::GEIGS_CHOLESKY
@ GEIGS_CHOLESKY
Using Cholesky decomposition to solve generalized eigenvalues.
Definition: GEigsMode.h:19
Spectra
Definition: LOBPCGSolver.h:19
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic >
NULL
#define NULL
Definition: ccolamd.c:609
ceres::Vector
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
Definition: gtsam/3rdparty/ceres/eigen.h:38
SymGEigsCholeskyOp.h
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Scalar
SCALAR Scalar
Definition: bench_gemm.cpp:46
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:05:22