MUQ  0.4.3
GeneralizedEigenSolver.h
Go to the documentation of this file.
1 #ifndef GENERALIZEDEIGENSOLVER_H
2 #define GENERALIZEDEIGENSOLVER_H
3 
4 
6 
7 #include <boost/property_tree/ptree_fwd.hpp>
8 #include <Eigen/Core>
9 
10 namespace muq{
11 namespace Modeling{
12 
23 
24  public:
25 
26  virtual ~GeneralizedEigenSolver() = default;
27 
28 
29  // /**
30  // Compute the generalized eigenvalues and eigenvectors of a symmetric system \f$Av = \lambda Bv\f$ .
31  // @param[in] A A shared pointer to a muq::Modeling::LinearOperator instance specifying the matrix A.
32  // @param[in] B A shared pointer to a muq::Modeling::LinearOperator instance specifying the matrix B. If not specified or set to nullptr, B will be set to the identity.
33  // */
34  // virtual GeneralizedEigenSolver& compute(std::shared_ptr<LinearOperator> const& A,
35  // std::shared_ptr<LinearOperator> B = nullptr) = 0;
36 
40  Eigen::VectorXd const& eigenvalues() const{return eigVals;}
41 
45  Eigen::MatrixXd const& eigenvectors() const{return eigVecs;};
46 
47  protected:
48 
52  static void SortCols(std::vector<std::pair<int,int>> const& swapInds,
53  Eigen::Ref<Eigen::MatrixXd> matrix);
54 
55  static void SortVec(std::vector<std::pair<int,int>> const& swapInds,
56  Eigen::Ref<Eigen::VectorXd> matrix);
57 
58  static void SortVec(std::vector<std::pair<int,int>> const& swapInds,
59  std::vector<bool> & vec);
63  static std::vector<std::pair<int,int>> GetSortSwaps(Eigen::Ref<const Eigen::VectorXd> const& residNorms,
64  std::vector<bool> const& isActive);
65 
66  static std::vector<std::pair<int,int>> GetSortSwaps(Eigen::Ref<const Eigen::VectorXd> const& residNorms);
67 
68  Eigen::VectorXd eigVals;
69  Eigen::MatrixXd eigVecs;
70 
71  std::shared_ptr<LinearOperator> A, B, M;
72  }; // class GeneralizedEigenSolver
73 
74 }
75 }
76 
77 #endif // #ifndef GENERALIZEDEIGENSOLVER_H
Abstract base class for operator based generalized eigenvalue solvers.
static std::vector< std::pair< int, int > > GetSortSwaps(Eigen::Ref< const Eigen::VectorXd > const &residNorms, std::vector< bool > const &isActive)
std::shared_ptr< LinearOperator > A
static void SortVec(std::vector< std::pair< int, int >> const &swapInds, Eigen::Ref< Eigen::VectorXd > matrix)
std::shared_ptr< LinearOperator > M
static void SortCols(std::vector< std::pair< int, int >> const &swapInds, Eigen::Ref< Eigen::MatrixXd > matrix)
Eigen::VectorXd const & eigenvalues() const
Eigen::MatrixXd const & eigenvectors() const
std::shared_ptr< LinearOperator > B