Commit 1f418dccc940b8bd6b6d8192decda64ebe0973b8
1 parent
d56df314
Adapt `optimize.cpp` example to name change in `GOptimizerFunction`.
Showing
1 changed file
with
10 additions
and
10 deletions
examples/cpp/optimize/optimize.cpp
| @@ -31,21 +31,21 @@ | @@ -31,21 +31,21 @@ | ||
| 31 | /***********************************************************************//** | 31 | /***********************************************************************//** |
| 32 | * @brief Parabola function | 32 | * @brief Parabola function |
| 33 | * | 33 | * |
| 34 | - * This code illustrates the definition of a Gaussian function. | 34 | + * This code illustrates the definition of a parabola function. |
| 35 | ***************************************************************************/ | 35 | ***************************************************************************/ |
| 36 | -class function : public GOptimizerFunction { | 36 | +class parabola : public GOptimizerFunction { |
| 37 | public: | 37 | public: |
| 38 | - function(void) : m_value(0), m_gradient(1), m_covar(1,1) {} | 38 | + parabola(void) : m_value(0), m_gradient(1), m_curvature(1,1) {} |
| 39 | void eval(const GOptimizerPars& pars); | 39 | void eval(const GOptimizerPars& pars); |
| 40 | double value(void) { return m_value; } | 40 | double value(void) { return m_value; } |
| 41 | GVector* gradient(void) { return &m_gradient; } | 41 | GVector* gradient(void) { return &m_gradient; } |
| 42 | - GMatrixSparse* covar(void) { return &m_covar; } | 42 | + GMatrixSparse* curvature(void) { return &m_curvature; } |
| 43 | protected: | 43 | protected: |
| 44 | - double m_value; //!< Function value | ||
| 45 | - GVector m_gradient; //!< Function gradient vector | ||
| 46 | - GMatrixSparse m_covar; //!< Covariance matrix | 44 | + double m_value; //!< Function value |
| 45 | + GVector m_gradient; //!< Function gradient vector | ||
| 46 | + GMatrixSparse m_curvature; //!< Curvature matrix | ||
| 47 | }; | 47 | }; |
| 48 | -void function::eval(const GOptimizerPars& pars) | 48 | +void parabola::eval(const GOptimizerPars& pars) |
| 49 | { | 49 | { |
| 50 | const double a = 2.0; | 50 | const double a = 2.0; |
| 51 | const double b = -4.0; | 51 | const double b = -4.0; |
| @@ -53,7 +53,7 @@ void function::eval(const GOptimizerPars& pars) | @@ -53,7 +53,7 @@ void function::eval(const GOptimizerPars& pars) | ||
| 53 | double x = pars[0]->value(); | 53 | double x = pars[0]->value(); |
| 54 | m_value = a*x*x + b*x + c; | 54 | m_value = a*x*x + b*x + c; |
| 55 | m_gradient[0] = 2.0*a*x + b; | 55 | m_gradient[0] = 2.0*a*x + b; |
| 56 | - m_covar(0,0) = m_gradient[0] * m_gradient[0]; | 56 | + m_curvature(0,0) = m_gradient[0] * m_gradient[0]; |
| 57 | }; | 57 | }; |
| 58 | 58 | ||
| 59 | 59 | ||
| @@ -73,7 +73,7 @@ int main(void) { | @@ -73,7 +73,7 @@ int main(void) { | ||
| 73 | GOptimizerLM opt; | 73 | GOptimizerLM opt; |
| 74 | 74 | ||
| 75 | // Allocate function | 75 | // Allocate function |
| 76 | - function fct; | 76 | + parabola fct; |
| 77 | 77 | ||
| 78 | // Allocate parameters and set initial value | 78 | // Allocate parameters and set initial value |
| 79 | GOptimizerPars pars(1); | 79 | GOptimizerPars pars(1); |