11#ifndef __MEAL_InverseRule_H
12#define __MEAL_InverseRule_H
14#include "MEAL/UnaryRule.h"
25 typedef typename T::Result Result;
45 void calculate (Result& result, std::vector<Result>* gradient);
54 return "InverseRule<" + std::string(T::Name)+
">";
60 std::vector<Result>* grad)
63 throw Error (InvalidState,
"MEAL::InverseRule::calculate",
64 "no model to evaluate");
67 std::cerr <<
"MEAL::InverseRule::calculate" << std::endl;
69 result = inv( this->
model->evaluate (grad) );
72 std::cerr <<
"MEAL::InverseRule::calculate result\n"
73 " " << result << std::endl;
78 for (
unsigned igrad=0; igrad<grad->size(); igrad++)
79 (*grad)[igrad] = - result * (*grad)[igrad] * result;
82 std::cerr <<
"MEAL::InverseRule::calculate gradient\n";
83 for (
unsigned i=0; i<grad->size(); i++)
85 << i <<
":" << this->get_infit(i) <<
"=" << (*grad)[i] << std::endl;
Computes the inverse of a model and its partial derivatives.
Definition InverseRule.h:21
std::string get_name() const
Return the name of the class.
Definition InverseRule.h:52
void calculate(Result &result, std::vector< Result > *gradient)
Return the Result and its gradient.
Definition InverseRule.h:59
UnaryRule()
Default constructor.
Definition UnaryRule.h:27
Project< T > model
The Function on which the operation will be performed.
Definition UnaryRule.h:44
Namespace in which all modeling and calibration related code is declared.
Definition ExampleComplex2.h:16