DenseGenRealShiftSolve.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 DENSE_GEN_REAL_SHIFT_SOLVE_H
8 #define DENSE_GEN_REAL_SHIFT_SOLVE_H
9 
10 #include <Eigen/Core>
11 #include <Eigen/LU>
12 #include <stdexcept>
13 
14 namespace Spectra {
15 
23 template <typename Scalar>
25 {
26 private:
33 
35  const Index m_n;
37 
38 public:
48  m_mat(mat), m_n(mat.rows())
49  {
50  if (mat.rows() != mat.cols())
51  throw std::invalid_argument("DenseGenRealShiftSolve: matrix must be square");
52  }
53 
57  Index rows() const { return m_n; }
61  Index cols() const { return m_n; }
62 
67  {
68  m_solver.compute(m_mat - sigma * Matrix::Identity(m_n, m_n));
69  }
70 
77  // y_out = inv(A - sigma * I) * x_in
78  void perform_op(const Scalar* x_in, Scalar* y_out) const
79  {
80  MapConstVec x(x_in, m_n);
81  MapVec y(y_out, m_n);
82  y.noalias() = m_solver.solve(x);
83  }
84 };
85 
86 } // namespace Spectra
87 
88 #endif // DENSE_GEN_REAL_SHIFT_SOLVE_H
Eigen::PartialPivLU
LU decomposition of a matrix with partial pivoting, and related features.
Definition: ForwardDeclarations.h:269
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
Spectra::DenseGenRealShiftSolve::DenseGenRealShiftSolve
DenseGenRealShiftSolve(ConstGenericMatrix &mat)
Definition: DenseGenRealShiftSolve.h:47
Spectra::DenseGenRealShiftSolve::m_n
const Index m_n
Definition: DenseGenRealShiftSolve.h:35
mat
MatrixXf mat
Definition: Tutorial_AdvancedInitialization_CommaTemporary.cpp:1
Spectra::DenseGenRealShiftSolve::rows
Index rows() const
Definition: DenseGenRealShiftSolve.h:57
sampling::sigma
static const double sigma
Definition: testGaussianBayesNet.cpp:170
Spectra::DenseGenRealShiftSolve::m_solver
Eigen::PartialPivLU< Matrix > m_solver
Definition: DenseGenRealShiftSolve.h:36
Spectra::DenseGenRealShiftSolve::set_shift
void set_shift(Scalar sigma)
Definition: DenseGenRealShiftSolve.h:66
Eigen::Map
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:94
y
Scalar * y
Definition: level1_cplx_impl.h:124
Spectra::DenseGenRealShiftSolve
Definition: DenseGenRealShiftSolve.h:24
Eigen::Ref
A matrix or vector expression mapping an existing expression.
Definition: Ref.h:281
Spectra::DenseGenRealShiftSolve::cols
Index cols() const
Definition: DenseGenRealShiftSolve.h:61
Spectra::DenseGenRealShiftSolve::ConstGenericMatrix
const typedef Eigen::Ref< const Matrix > ConstGenericMatrix
Definition: DenseGenRealShiftSolve.h:32
Spectra
Definition: LOBPCGSolver.h:19
Spectra::DenseGenRealShiftSolve::m_mat
ConstGenericMatrix m_mat
Definition: DenseGenRealShiftSolve.h:34
Spectra::DenseGenRealShiftSolve::Vector
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
Definition: DenseGenRealShiftSolve.h:29
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic >
Spectra::DenseGenRealShiftSolve::MapConstVec
Eigen::Map< const Vector > MapConstVec
Definition: DenseGenRealShiftSolve.h:30
Spectra::DenseGenRealShiftSolve::MapVec
Eigen::Map< Vector > MapVec
Definition: DenseGenRealShiftSolve.h:31
Spectra::DenseGenRealShiftSolve::perform_op
void perform_op(const Scalar *x_in, Scalar *y_out) const
Definition: DenseGenRealShiftSolve.h:78
Spectra::DenseGenRealShiftSolve::Index
Eigen::Index Index
Definition: DenseGenRealShiftSolve.h:27
Scalar
SCALAR Scalar
Definition: bench_gemm.cpp:46
Spectra::DenseGenRealShiftSolve::Matrix
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > Matrix
Definition: DenseGenRealShiftSolve.h:28
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:02:12