Tomato
OxModelT1AdapterVnlLeastSquares.h
Go to the documentation of this file.
1 
7 #ifndef Tomato_OXModelT1ADAPTERVNLLEASTSQUARES_H
8 #define Tomato_OXModelT1ADAPTERVNLLEASTSQUARES_H
9 
10 #include "CmakeConfigForTomato.h"
11 #ifdef USE_VNL
12 
13 #include <vnl/vnl_least_squares_function.h>
14 
15 #include "OxModel.h"
16 
17 namespace Ox {
18 
19  class ModelT1AdapterVnlLeastSquares : public vnl_least_squares_function {
20 
21  public:
22 
23  // least squares function problem formulation
24  void f(vnl_vector<double> const& params, vnl_vector<double> &residuals){
25 
26  //_Model->copyToParameters(params.data_block());
27  _ModelT1->calcLSResiduals(params.data_block(), residuals.data_block());
28  }
29 
30  // least squares function gradient
31  void gradf (vnl_vector< double > const &params, vnl_matrix< double > &jacobianVNL){
32 
33  //_Model->copyToParameters(params.data_block());
34  _ModelT1->calcLSJacobian(params.data_block(), jacobianVNL.data_block());
35  }
36 
37  void setModel(Model<double>* _ModelT1){
38  this->_ModelT1 = _ModelT1;
39  };
40 
41  // getters
42  Model<double>* getModel(){
43  return _ModelT1;
44  };
45 
49  ModelT1AdapterVnlLeastSquares(int nDims, int nSamples, UseGradient UseGradientVariable)
50  : vnl_least_squares_function (nDims, nSamples, UseGradientVariable){
51  _ModelT1 = 0; // nullpointer
52  };
53 
58  ModelT1AdapterVnlLeastSquares(const ModelT1AdapterVnlLeastSquares &old)
59  : vnl_least_squares_function(old){
60  _ModelT1 = old._ModelT1;
61  }
62 
63  private:
64 
65  Model<double>* _ModelT1;
66  };
67 
68 } // namespace Ox
69 
70 #endif //USE_VNL
71 
72 #endif //Tomato_OXModelT1ADAPTERVNLLEASTSQUARES_H
Definition: OxCalculator.h:19