SymGEigsBucklingOp.h
Go to the documentation of this file.
1 // Copyright (C) 2020-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_BUCKLING_OP_H
8 #define SPECTRA_SYM_GEIGS_BUCKLING_OP_H
9 
10 #include <Eigen/Core>
11 
12 #include "../SymShiftInvert.h"
13 #include "../SparseSymMatProd.h"
14 
15 namespace Spectra {
16 
26 template <typename OpType = SymShiftInvert<double>,
27  typename BOpType = SparseSymMatProd<double>>
29 {
30 public:
31  using Scalar = typename OpType::Scalar;
32 
33 private:
36 
37  OpType& m_op;
38  const BOpType& m_Bop;
39  mutable Vector m_cache; // temporary working space
40 
41 public:
48  SymGEigsBucklingOp(OpType& op, const BOpType& Bop) :
49  m_op(op), m_Bop(Bop), m_cache(op.rows())
50  {}
51 
57  {
58  // We emulate the move constructor for Vector using Vector::swap()
59  m_cache.swap(other.m_cache);
60  }
61 
65  Index rows() const { return m_op.rows(); }
69  Index cols() const { return m_op.rows(); }
70 
74  void set_shift(const Scalar& sigma)
75  {
76  m_op.set_shift(sigma);
77  }
78 
85  // y_out = inv(K - sigma * K_G) * K * x_in
86  void perform_op(const Scalar* x_in, Scalar* y_out) const
87  {
88  m_Bop.perform_op(x_in, m_cache.data());
89  m_op.perform_op(m_cache.data(), y_out);
90  }
91 };
92 
93 } // namespace Spectra
94 
95 #endif // SPECTRA_SYM_GEIGS_BUCKLING_OP_H
Spectra::SymGEigsBucklingOp::perform_op
void perform_op(const Scalar *x_in, Scalar *y_out) const
Definition: SymGEigsBucklingOp.h:86
Spectra::SymGEigsBucklingOp
Definition: SymGEigsBucklingOp.h:28
Eigen::PlainObjectBase::swap
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void swap(DenseBase< OtherDerived > &other)
Definition: PlainObjectBase.h:953
Spectra::SymGEigsBucklingOp::cols
Index cols() const
Definition: SymGEigsBucklingOp.h:69
Spectra::SymGEigsBucklingOp::m_Bop
const BOpType & m_Bop
Definition: SymGEigsBucklingOp.h:38
sampling::sigma
static const double sigma
Definition: testGaussianBayesNet.cpp:170
Spectra::SymGEigsBucklingOp::set_shift
void set_shift(const Scalar &sigma)
Definition: SymGEigsBucklingOp.h:74
Spectra::SymGEigsBucklingOp::SymGEigsBucklingOp
SymGEigsBucklingOp(OpType &op, const BOpType &Bop)
Definition: SymGEigsBucklingOp.h:48
Spectra::SymGEigsBucklingOp::rows
Index rows() const
Definition: SymGEigsBucklingOp.h:65
Spectra::SymGEigsBucklingOp::m_cache
Vector m_cache
Definition: SymGEigsBucklingOp.h:39
Spectra::SymGEigsBucklingOp::Index
Eigen::Index Index
Definition: SymGEigsBucklingOp.h:34
Spectra
Definition: LOBPCGSolver.h:19
Eigen::PlainObjectBase::data
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE Scalar * data() const
Definition: PlainObjectBase.h:247
Spectra::SymGEigsBucklingOp::Scalar
typename OpType::Scalar Scalar
Definition: SymGEigsBucklingOp.h:31
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 >
Spectra::SymGEigsBucklingOp::m_op
OpType & m_op
Definition: SymGEigsBucklingOp.h:37
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42
Scalar
SCALAR Scalar
Definition: bench_gemm.cpp:46
Spectra::SymGEigsBucklingOp::SymGEigsBucklingOp
SymGEigsBucklingOp(SymGEigsBucklingOp &&other)
Definition: SymGEigsBucklingOp.h:55
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 Wed Apr 16 2025 03:05:33