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  {
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
SCALAR Scalar
Definition: bench_gemm.cpp:46
Using Cholesky decomposition to solve generalized eigenvalues.
Definition: GEigsMode.h:19
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > Matrix
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
#define NULL
Definition: ccolamd.c:609
Regular inverse mode for generalized eigenvalue solver.
Definition: GEigsMode.h:21
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:36:35