MUQ  0.4.3
ScaleVector.cpp
Go to the documentation of this file.
2 
3 using namespace muq::Modeling;
4 
5 ScaleVector::ScaleVector(double const scale, unsigned int const dim) : ModPiece(Eigen::VectorXi::Constant(1, dim), Eigen::VectorXi::Constant(1, dim)), scale(scale) {}
6 
8  outputs.resize(1);
9  outputs[0] = scale*inputs[0];
10 }
11 
12 void ScaleVector::JacobianImpl(unsigned int const outwrt, unsigned int const inwrt, ref_vector<Eigen::VectorXd> const& inputs) {
13  jacobian = scale*Eigen::MatrixXd::Identity(outputSizes(0), inputSizes(0));
14 }
15 
16 void ScaleVector::GradientImpl(unsigned int const outwrt, unsigned int const inwrt, ref_vector<Eigen::VectorXd> const& inputs, Eigen::VectorXd const& sens) {
17  gradient = scale*sens;
18 }
19 
20 void ScaleVector::ApplyJacobianImpl(unsigned int const outwrt, unsigned int const inwrt, ref_vector<Eigen::VectorXd> const& inputs, Eigen::VectorXd const& targ) {
21  jacobianAction = scale*targ;
22 }
Provides an abstract interface for defining vector-valued model components.
Definition: ModPiece.h:148
Eigen::MatrixXd jacobian
Definition: ModPiece.h:506
const Eigen::VectorXi inputSizes
Definition: ModPiece.h:469
std::vector< Eigen::VectorXd > outputs
Definition: ModPiece.h:503
Eigen::VectorXd gradient
Definition: ModPiece.h:504
const Eigen::VectorXi outputSizes
Definition: ModPiece.h:472
Eigen::VectorXd jacobianAction
Definition: ModPiece.h:505
virtual void ApplyJacobianImpl(unsigned int const outwrt, unsigned int const inwrt, ref_vector< Eigen::VectorXd > const &inputs, Eigen::VectorXd const &targ) override
Definition: ScaleVector.cpp:20
virtual void GradientImpl(unsigned int const outwrt, unsigned int const inwrt, ref_vector< Eigen::VectorXd > const &inputs, Eigen::VectorXd const &sens) override
Definition: ScaleVector.cpp:16
virtual void EvaluateImpl(ref_vector< Eigen::VectorXd > const &inputs) override
Definition: ScaleVector.cpp:7
virtual void JacobianImpl(unsigned int const outwrt, unsigned int const inwrt, ref_vector< Eigen::VectorXd > const &inputs) override
Definition: ScaleVector.cpp:12
ScaleVector(double const scale, unsigned int const dim)
Definition: ScaleVector.cpp:5
std::vector< std::reference_wrapper< const T > > ref_vector
A vector of references to something ...
Definition: WorkPiece.h:37