SymGEigsRegInvOp.h
Go to the documentation of this file.
1 // Copyright (C) 2017-2025 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 SPECTRA_SYM_GEIGS_REG_INV_OP_H
8 #define SPECTRA_SYM_GEIGS_REG_INV_OP_H
9 
10 #include <Eigen/Core>
11 
12 #include "../SparseSymMatProd.h"
13 #include "../SparseRegularInverse.h"
14 
15 namespace Spectra {
16 
23 template <typename OpType = SparseSymMatProd<double>,
24  typename BOpType = SparseRegularInverse<double>>
26 {
27 public:
28  using Scalar = typename OpType::Scalar;
29 
30 private:
33 
34  const OpType& m_op;
35  const BOpType& m_Bop;
36  mutable Vector m_cache; // temporary working space
37 
38 public:
45  SymGEigsRegInvOp(const OpType& op, const BOpType& Bop) :
46  m_op(op), m_Bop(Bop), m_cache(op.rows())
47  {}
48 
54  {
55  // We emulate the move constructor for Vector using Vector::swap()
56  m_cache.swap(other.m_cache);
57  }
58 
62  Index rows() const { return m_Bop.rows(); }
66  Index cols() const { return m_Bop.rows(); }
67 
74  // y_out = inv(B) * A * x_in
75  void perform_op(const Scalar* x_in, Scalar* y_out) const
76  {
77  m_op.perform_op(x_in, m_cache.data());
78  m_Bop.solve(m_cache.data(), y_out);
79  }
80 };
81 
82 } // namespace Spectra
83 
84 #endif // SPECTRA_SYM_GEIGS_REG_INV_OP_H
Eigen::PlainObjectBase::swap
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void swap(DenseBase< OtherDerived > &other)
Definition: PlainObjectBase.h:953
Spectra::SymGEigsRegInvOp::SymGEigsRegInvOp
SymGEigsRegInvOp(SymGEigsRegInvOp &&other)
Definition: SymGEigsRegInvOp.h:52
Spectra::SymGEigsRegInvOp::Index
Eigen::Index Index
Definition: SymGEigsRegInvOp.h:31
Spectra::SymGEigsRegInvOp::m_Bop
const BOpType & m_Bop
Definition: SymGEigsRegInvOp.h:35
Spectra::SymGEigsRegInvOp::cols
Index cols() const
Definition: SymGEigsRegInvOp.h:66
Spectra::SymGEigsRegInvOp::m_cache
Vector m_cache
Definition: SymGEigsRegInvOp.h:36
Spectra::SymGEigsRegInvOp::rows
Index rows() const
Definition: SymGEigsRegInvOp.h:62
Spectra::SymGEigsRegInvOp::m_op
const OpType & m_op
Definition: SymGEigsRegInvOp.h:34
Spectra::SymGEigsRegInvOp
Definition: SymGEigsRegInvOp.h:25
Spectra::SymGEigsRegInvOp::perform_op
void perform_op(const Scalar *x_in, Scalar *y_out) const
Definition: SymGEigsRegInvOp.h:75
Spectra
Definition: LOBPCGSolver.h:19
Eigen::PlainObjectBase::data
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE Scalar * data() const
Definition: PlainObjectBase.h:247
Spectra::SymGEigsRegInvOp::Scalar
typename OpType::Scalar Scalar
Definition: SymGEigsRegInvOp.h:28
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 >
Spectra::SymGEigsRegInvOp::SymGEigsRegInvOp
SymGEigsRegInvOp(const OpType &op, const BOpType &Bop)
Definition: SymGEigsRegInvOp.h:45
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42
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 Thu Apr 10 2025 03:04:25