MUQ  0.4.3
AffineOperator.h
Go to the documentation of this file.
1 #ifndef AFFINEOPERATOR_H
2 #define AFFINEOPERATOR_H
3 
6 
7 #include <Eigen/Core>
8 
9 #include <memory>
10 #include <iostream>
11 #include <exception>
12 
13 namespace muq
14 {
15 namespace Modeling
16 {
17 
36 public:
37 
38  template<typename T>
39  AffineOperator(T const& Ain, Eigen::VectorXd const& bIn) : AffineOperator(LinearOperator::Create(Ain), bIn) {}
40 
41  AffineOperator(std::shared_ptr<LinearOperator> const& Ain, Eigen::VectorXd const& bIn);
42 
43  virtual ~AffineOperator(){};
44 
46  std::shared_ptr<LinearOperator> Linear() const{return A;};
47 
49  Eigen::VectorXd const& Offset() const{return b;};
50 
52  int rows() const { return A->rows(); }
53 
55  int cols() const { return A->cols(); }
56 
57  template<typename OtherType>
58  static std::shared_ptr<AffineOperator> Create(OtherType const& A, Eigen::VectorXd const& b)
59  {
60  return std::make_shared<AffineOperator>(LinearOperatorFactory<OtherType>::Create(A),b);
61  }
62 
63 protected:
64 
65  std::shared_ptr<LinearOperator> A;
66  Eigen::VectorXd b;
67 
68  // ModPiece overrides
69  virtual void EvaluateImpl(muq::Modeling::ref_vector<Eigen::VectorXd> const& input) override;
70 
71  virtual void GradientImpl(unsigned int const outputDimWrt,
72  unsigned int const inputDimWrt,
74  Eigen::VectorXd const& sensitivity) override;
75 
76  virtual void JacobianImpl(unsigned int const outputDimWrt,
77  unsigned int const inputDimWrt,
78  muq::Modeling::ref_vector<Eigen::VectorXd> const& input) override;
79 
80  virtual void ApplyJacobianImpl(unsigned int const outputDimWrt,
81  unsigned int const inputDimWrt,
83  Eigen::VectorXd const& vec) override;
84 };
85 
86 
87 
88 
89 } // namespace Modeling
90 } // namespace MUQ
91 
92 #endif
Generic affine operator which adds an offset to a linear operator. @seealso LinearOperator.
AffineOperator(T const &Ain, Eigen::VectorXd const &bIn)
virtual void ApplyJacobianImpl(unsigned int const outputDimWrt, unsigned int const inputDimWrt, muq::Modeling::ref_vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &vec) override
std::shared_ptr< LinearOperator > Linear() const
Eigen::VectorXd const & Offset() const
virtual void EvaluateImpl(muq::Modeling::ref_vector< Eigen::VectorXd > const &input) override
virtual void JacobianImpl(unsigned int const outputDimWrt, unsigned int const inputDimWrt, muq::Modeling::ref_vector< Eigen::VectorXd > const &input) override
static std::shared_ptr< AffineOperator > Create(OtherType const &A, Eigen::VectorXd const &b)
virtual void GradientImpl(unsigned int const outputDimWrt, unsigned int const inputDimWrt, muq::Modeling::ref_vector< Eigen::VectorXd > const &input, Eigen::VectorXd const &sensitivity) override
std::shared_ptr< LinearOperator > A
Generic linear operator base class.
Provides an abstract interface for defining vector-valued model components.
Definition: ModPiece.h:148
std::vector< std::reference_wrapper< const T > > ref_vector
A vector of references to something ...
Definition: WorkPiece.h:37