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 
34  ConstGenericMatrix m_mat;
35  const Index m_n;
37 
38 public:
47  DenseGenRealShiftSolve(ConstGenericMatrix& mat) :
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
SCALAR Scalar
Definition: bench_gemm.cpp:33
PartialPivLU & compute(const EigenBase< InputType > &matrix)
Definition: PartialPivLU.h:129
Scalar * y
void perform_op(const Scalar *x_in, Scalar *y_out) const
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:94
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > Matrix
static const double sigma
LU decomposition of a matrix with partial pivoting, and related features.
const Eigen::Ref< const Matrix > ConstGenericMatrix
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
Eigen::PartialPivLU< Matrix > m_solver
DenseGenRealShiftSolve(ConstGenericMatrix &mat)
Eigen::Map< const Vector > MapConstVec
const Solve< PartialPivLU, Rhs > solve(const MatrixBase< Rhs > &b) const
Definition: PartialPivLU.h:175
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


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:41:58