MUQ  0.4.3
AffineOperator.cpp
Go to the documentation of this file.
2 
3 
4 using namespace muq::Modeling;
5 
6 AffineOperator::AffineOperator(std::shared_ptr<LinearOperator> const& Ain,
7  Eigen::VectorXd const& bIn) : ModPiece(Ain->inputSizes,
8  Ain->outputSizes),
9  A(Ain),
10  b(bIn)
11 {
12  assert(A->rows()==b.rows());
13 };
14 
16 {
17  outputs.resize(1);
18  outputs.at(0) = b + A->Apply(input.at(0).get()).col(0);
19 }
20 
21 void AffineOperator::GradientImpl(unsigned int const outputDimWrt,
22  unsigned int const inputDimWrt,
24  Eigen::VectorXd const& sensitivity)
25 {
26  gradient = A->ApplyTranspose(sensitivity);
27 }
28 
29 void AffineOperator::JacobianImpl(unsigned int const outputDimWrt,
30  unsigned int const inputDimWrt,
32 {
33  jacobian = A->GetMatrix();
34 }
35 
36 void AffineOperator::ApplyJacobianImpl(unsigned int const outputDimWrt,
37  unsigned int const inputDimWrt,
39  Eigen::VectorXd const& vec)
40 {
41  jacobianAction = A->Apply(vec);
42 }
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
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
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
Provides an abstract interface for defining vector-valued model components.
Definition: ModPiece.h:148
Eigen::MatrixXd jacobian
Definition: ModPiece.h:506
std::vector< Eigen::VectorXd > outputs
Definition: ModPiece.h:503
Eigen::VectorXd gradient
Definition: ModPiece.h:504
Eigen::VectorXd jacobianAction
Definition: ModPiece.h:505
std::vector< std::reference_wrapper< const T > > ref_vector
A vector of references to something ...
Definition: WorkPiece.h:37