Home
Install
Use
Develop
Support
News
Credits
hosted by
|
11#ifndef __MEAL_BasisRule_H
12#define __MEAL_BasisRule_H
15#include "MEAL/Composite.h"
28 template< unsigned N, class T>
34 typedef typename T::Result Result;
63 void calculate (Result& result, std::vector<Result>* gradient);
90template< unsigned N, class T>
93 return "BasisRule<" + tostring(N) + "," + std::string(T::Name)+ ">";
96template< unsigned N, class T>
109template< unsigned N, class T>
115 std::cerr << "MEAL::BasisRule::set_model"
116 " unmap old model" << std::endl;
117 composite.unmap ( model);
126 std::cerr << "MEAL::BasisRule::set_model"
127 " map new model" << std::endl;
129 composite.map ( model);
131 Vector<N,double> params;
133 for ( unsigned i=0; i<N; i++)
135 model->set_infit (i, false);
136 params[i] = model->get_param(i);
141 for ( unsigned i=0; i<N; i++)
146template< unsigned N, class T>
154 Vector<N,double> params;
156 for ( unsigned i=0; i<N; i++)
157 params[i] = model->get_param(i);
161 for ( unsigned i=0; i<N; i++)
165template< unsigned N, class T>
167 std::vector<Result>* grad)
170 throw Error (InvalidState, "MEAL::BasisRule::calculate", "no model");
173 std::cerr << "MEAL::BasisRule::calculate" << std::endl;
175 Vector<N,double> params;
176 for ( unsigned i=0; i<N; i++)
181 for ( unsigned i=0; i<N; i++)
182 model->set_param (i, params[i]);
184 std::vector<Result> model_grad;
185 std::vector<Result>* model_grad_ptr = 0;
187 model_grad_ptr = & model_grad;
189 result = model->evaluate (model_grad_ptr);
193 unsigned ngrad = this->get_nparam();
194 grad->resize (ngrad);
197 for (igrad=0; igrad<ngrad; igrad++)
198 (*grad)[igrad] = 0.0;
201 ProjectGradient ( model, model_grad, *(grad));
204 std::vector<Result> fgrad (N, 0);
206 for (igrad=0; igrad<N; igrad++)
207 for ( unsigned idep=0; idep<N; idep++)
210 ProjectGradient ( project, fgrad, *(grad));
215 std::cerr << "MEAL::BasisRule::calculate result\n"
216 " " << result << std::endl;
218 std::cerr << "MEAL::BasisRule::calculate gradient\n";
219 for ( unsigned i=0; i<grad->size(); i++)
220 std::cerr << " " << i << ":" << this->get_infit(i) << "="
221 << (*grad)[i] << std::endl;
Changes the basis of the parameterization. Definition BasisRule.h:30
Project< T > model The Function with the parameters to be transformed. Definition BasisRule.h:66
BasisRule(const BasisRule &rule) Copy constructor. Definition BasisRule.h:40
Matrix< N, N, double > transformation The basis transformation. Definition BasisRule.h:75
BasisRule() Default constructor. Definition BasisRule.h:37
void set_transformation(const Matrix< N, N, double > &xform) Set the basis transformation. Definition BasisRule.h:147
std::string get_name() const Return the name of the class. Definition BasisRule.h:91
void set_model(T *model) Set the Function with the parameters to be transformed. Definition BasisRule.h:110
Null parameters The free parameters. Definition BasisRule.h:69
Project< Null > project The projection of the free parameters. Definition BasisRule.h:72
void calculate(Result &result, std::vector< Result > *gradient) Return the Result and its gradient. Definition BasisRule.h:166
BasisRule & operator=(const BasisRule &rule) Assignment operator. Definition BasisRule.h:98
Parameter policy for composite functions. Definition Composite.h:20
Null function holds an arbitrary number of parameters. Definition Null.h:20
Template combines a reference to a Component and its Projection. Definition Projection.h:60
Namespace in which all modeling and calibration related code is declared. Definition ExampleComplex2.h:16
Generated using doxygen 1.14.0
|