26#ifndef UTILS_TRICHOTOMY_dot_HH
27#define UTILS_TRICHOTOMY_dot_HH
70 template <
typename Real>
79 virtual Real
eval( Real x )
const = 0;
89 #ifndef DOXYGEN_SHOULD_SKIP_THIS
90 template <
typename Real,
typename PFUN>
91 class Trichotomy_fun :
public Trichotomy_base_fun<Real> {
94 explicit Trichotomy_fun( PFUN pfun ) : m_fun(pfun) {}
95 Real eval( Real x )
const override {
return m_fun(x); };
129 template <
typename Real>
134 Integer m_num_iter_done{0};
135 Integer m_num_fun_eval{0};
136 Integer m_max_iteration{100};
137 Integer m_max_fun_evaluation{1000};
140 bool m_converged{
false};
142 Real m_a{0}, m_fa{0};
143 Real m_x1{0}, m_f1{0};
144 Real m_x2{0}, m_f2{0};
145 Real m_x3{0}, m_f3{0};
146 Real m_x4{0}, m_f4{0};
147 Real m_x5{0}, m_f5{0};
148 Real m_b{0}, m_fb{0};
155 Real evaluate( Real x ) { ++m_num_fun_eval;
return m_function->eval(x); };
156 Real eval( Real a, Real b );
157 Real search( Real x, Real delta );
175 return this->eval( a, b );
186 template <
typename PFUN>
188 eval2( Real a, Real b, PFUN pfun ) {
189 Trichotomy_fun<Real,PFUN> fun( pfun );
191 return this->eval(a,b);
205 return this->search( x, delta );
216 template <
typename PFUN>
219 Trichotomy_fun<Real,PFUN> fun( pfun );
221 return this->search( x, delta );
256 #ifndef UTILS_OS_WINDOWS
257 extern template class Trichotomy<float>;
258 extern template class Trichotomy<double>;
Abstract base class for defining mathematical functions used in the minimization algorithm.
Definition Utils_Trichotomy.hh:71
virtual Real eval(Real x) const =0
Real operator()(Real x) const
Definition Utils_Trichotomy.hh:86
Integer num_fun_eval() const
Definition Utils_Trichotomy.hh:231
void set_max_iterations(Integer mit)
Definition Utils_Trichotomy.cc:43
Real search2(Real x, Real delta, PFUN pfun)
Definition Utils_Trichotomy.hh:218
Real tolerance() const
Definition Utils_Trichotomy.hh:235
bool converged() const
Definition Utils_Trichotomy.hh:239
Real search(Real x, Real delta, Trichotomy_base_fun< Real > *fun)
Definition Utils_Trichotomy.hh:203
void set_max_fun_evaluation(Integer mfev)
Definition Utils_Trichotomy.cc:57
Real eval2(Real a, Real b, PFUN pfun)
Definition Utils_Trichotomy.hh:188
Integer used_iter() const
Definition Utils_Trichotomy.hh:227
Real eval(Real a, Real b, Trichotomy_base_fun< Real > *fun)
Definition Utils_Trichotomy.hh:173
Definition SystemUtils.cc:39