MUQ  0.4.3
JacobianPiece.cpp
Go to the documentation of this file.
2 
3 using namespace muq::Modeling;
4 
5 
6 JacobianPiece::JacobianPiece(std::shared_ptr<ModPiece> const& basePieceIn,
7  unsigned int const outWrtIn,
8  unsigned int const inWrtIn) : ModPiece(GetInputSizes(basePieceIn, inWrtIn),
9  GetOutputSizes(basePieceIn, outWrtIn)),
10  basePiece(basePieceIn),
11  outWrt(outWrtIn),
12  inWrt(inWrtIn)
13 {
14 }
15 
16 Eigen::VectorXi JacobianPiece::GetInputSizes(std::shared_ptr<ModPiece> const& basePiece,
17  unsigned int const inWrt)
18 {
19  assert(inWrt < basePiece->inputSizes.size());
20 
21  unsigned int numInputs = basePiece->inputSizes.size() + 1;
22  Eigen::VectorXi inputSizes(numInputs);
23  inputSizes.head(numInputs-1) = basePiece->inputSizes;
24  inputSizes(numInputs-1) = basePiece->inputSizes(inWrt);
25 
26  return inputSizes;
27 }
28 
29 Eigen::VectorXi JacobianPiece::GetOutputSizes(std::shared_ptr<ModPiece> const& basePiece,
30  unsigned int const outWrt)
31 {
32  Eigen::VectorXi outputSizes(1);
33  outputSizes(0) = basePiece->outputSizes(outWrt);
34  return outputSizes;
35 }
36 
37 
39 {
40  ref_vector<Eigen::VectorXd> baseInputs(input.begin(), input.end()-1);
41 
42  outputs.resize(1);
43  outputs.at(0) = basePiece->ApplyJacobian(outWrt, inWrt, baseInputs, input.at(input.size()-1).get());
44 }
const unsigned int outWrt
Definition: JacobianPiece.h:38
std::shared_ptr< ModPiece > basePiece
Definition: JacobianPiece.h:36
virtual void EvaluateImpl(ref_vector< Eigen::VectorXd > const &input) override
static Eigen::VectorXi GetInputSizes(std::shared_ptr< ModPiece > const &basePiece, unsigned int const outWrt)
JacobianPiece(std::shared_ptr< ModPiece > const &basePieceIn, unsigned int const outWrt, unsigned int const inWrt)
const unsigned int inWrt
Definition: JacobianPiece.h:38
static Eigen::VectorXi GetOutputSizes(std::shared_ptr< ModPiece > const &basePiece, unsigned int const inWrt)
Provides an abstract interface for defining vector-valued model components.
Definition: ModPiece.h:148
const Eigen::VectorXi inputSizes
Definition: ModPiece.h:469
std::vector< Eigen::VectorXd > outputs
Definition: ModPiece.h:503
const Eigen::VectorXi outputSizes
Definition: ModPiece.h:472
int numInputs
The number of inputs.
Definition: WorkPiece.h:501
std::vector< std::reference_wrapper< const T > > ref_vector
A vector of references to something ...
Definition: WorkPiece.h:37