![]() |
UtilsLite
Utilities for C++ programming
|
Class for minimize the function \( f(x) \) without the usew of derivative. More...
#include <Utils_Trichotomy.hh>
Public Member Functions | |
Trichotomy ()=default | |
~Trichotomy ()=default | |
Real | eval (Real a, Real b, Trichotomy_base_fun< Real > *fun) |
template<typename PFUN> | |
Real | eval2 (Real a, Real b, PFUN pfun) |
Real | search (Real x, Real delta, Trichotomy_base_fun< Real > *fun) |
template<typename PFUN> | |
Real | search2 (Real x, Real delta, PFUN pfun) |
Integer | used_iter () const |
Integer | num_fun_eval () const |
Real | tolerance () const |
bool | converged () const |
void | set_max_iterations (Integer mit) |
void | set_max_fun_evaluation (Integer mfev) |
Class for minimize the function \( f(x) \) without the usew of derivative.
Usage Example
To use this class, first wrap your function in a derived class. For instance, for the function \( f(x) = x^2 - 2 \), you can define:
Next, instantiate the function and the solver. Then, call the desired method to find the root:
If the method converges, x_solution
will contain the computed solution.
|
default |
|
default |
|
inline |
|
inline |
Find the minimum of a function wrapped in the class Trichotomy_base_fun<Real>
starting from guess interval [a,b]
a | lower bound search interval |
b | upper bound search interval |
fun | the pointer to base class Trichotomy_base_fun<Real> wrapping the user function |
|
inline |
Find the minimum of a function pfun
starting from guess interval [a,b]
a | lower bound search interval |
b | upper bound search interval |
pfun | the pointer to base class Trichotomy_base_fun<Real> wrapping the user function |
|
inline |
|
inline |
Find the minimum of a function wrapped in the class Trichotomy_base_fun<Real>
starting from guess interval [x-delta,x+delta]
x | center of the search interval |
delta | ray of th eseaerch interval |
fun | the pointer to base class Trichotomy_base_fun<Real> wrapping the user function |
|
inline |
Find the minimum of a function object starting from guess interval [x-delta,x+delta]
x | center of the search interval |
delta | ray of th eseaerch interval |
pfun | the function object |
void Utils::Trichotomy< Real >::set_max_fun_evaluation | ( | Integer | mfev | ) |
Fix the maximum number of evaluation.
mfev | the maximum number of evaluation of \( f(x) \) |
void Utils::Trichotomy< Real >::set_max_iterations | ( | Integer | mit | ) |
Fix the maximum number of iteration.
mit | the maximum number of iteration |
|
inline |
|
inline |