SymGEigsCholeskyOp.h
Go to the documentation of this file.
1 // Copyright (C) 2016-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_CHOLESKY_OP_H
8 #define SPECTRA_SYM_GEIGS_CHOLESKY_OP_H
9 
10 #include <Eigen/Core>
11 
12 #include "../DenseSymMatProd.h"
13 #include "../DenseCholesky.h"
14 
15 namespace Spectra {
16 
25 template <typename OpType = DenseSymMatProd<double>,
26  typename BOpType = DenseCholesky<double>>
28 {
29 public:
30  using Scalar = typename OpType::Scalar;
31 
32 private:
35 
36  const OpType& m_op;
37  const BOpType& m_Bop;
38  mutable Vector m_cache; // temporary working space
39 
40 public:
47  SymGEigsCholeskyOp(const OpType& op, const BOpType& Bop) :
48  m_op(op), m_Bop(Bop), m_cache(op.rows())
49  {}
50 
56  {
57  // We emulate the move constructor for Vector using Vector::swap()
58  m_cache.swap(other.m_cache);
59  }
60 
64  Index rows() const { return m_Bop.rows(); }
68  Index cols() const { return m_Bop.rows(); }
69 
76  // y_out = inv(L) * A * inv(L') * x_in
77  void perform_op(const Scalar* x_in, Scalar* y_out) const
78  {
79  m_Bop.upper_triangular_solve(x_in, y_out);
80  m_op.perform_op(y_out, m_cache.data());
81  m_Bop.lower_triangular_solve(m_cache.data(), y_out);
82  }
83 };
84 
85 } // namespace Spectra
86 
87 #endif // SPECTRA_SYM_GEIGS_CHOLESKY_OP_H
Spectra::SymGEigsCholeskyOp::cols
Index cols() const
Definition: SymGEigsCholeskyOp.h:68
Spectra::SymGEigsCholeskyOp::Scalar
typename OpType::Scalar Scalar
Definition: SymGEigsCholeskyOp.h:30
Eigen::PlainObjectBase::swap
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void swap(DenseBase< OtherDerived > &other)
Definition: PlainObjectBase.h:953
Spectra::SymGEigsCholeskyOp::perform_op
void perform_op(const Scalar *x_in, Scalar *y_out) const
Definition: SymGEigsCholeskyOp.h:77
Spectra::SymGEigsCholeskyOp::m_cache
Vector m_cache
Definition: SymGEigsCholeskyOp.h:38
Spectra::SymGEigsCholeskyOp::SymGEigsCholeskyOp
SymGEigsCholeskyOp(const OpType &op, const BOpType &Bop)
Definition: SymGEigsCholeskyOp.h:47
Spectra::SymGEigsCholeskyOp
Definition: SymGEigsCholeskyOp.h:27
Spectra::SymGEigsCholeskyOp::SymGEigsCholeskyOp
SymGEigsCholeskyOp(SymGEigsCholeskyOp &&other)
Definition: SymGEigsCholeskyOp.h:54
Spectra
Definition: LOBPCGSolver.h:19
Spectra::SymGEigsCholeskyOp::m_Bop
const BOpType & m_Bop
Definition: SymGEigsCholeskyOp.h:37
Eigen::PlainObjectBase::data
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE Scalar * data() const
Definition: PlainObjectBase.h:247
Spectra::SymGEigsCholeskyOp::rows
Index rows() const
Definition: SymGEigsCholeskyOp.h:64
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 >
Spectra::SymGEigsCholeskyOp::m_op
const OpType & m_op
Definition: SymGEigsCholeskyOp.h:36
Spectra::SymGEigsCholeskyOp::Index
Eigen::Index Index
Definition: SymGEigsCholeskyOp.h:33
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 Wed Apr 16 2025 03:05:33