18 #ifndef INTERPOLANT_IMPL_H 19 #define INTERPOLANT_IMPL_H 55 template<
template<
class>
class Func,
class Type >
58 interpolate_derivative(interpolate_derivative)
64 func_diffn->set_param_from_func(func);
70 template<
template<
class>
class Func,
class Type >
78 func_diffn->set_param_from_func(func);
210 return func->operator()(x);
274 double x_step = x /
step;
288 double x_step = x /
step;
305 : interpolant(interpolant),
p_(p),
tol_(tol) {}
307 inline double p() {
return p_;}
315 return std::pow(a,
p_);
331 : interpolant(interpolant),
p_(p),
tol_(tol) {}
333 inline double p() {
return p_;}
340 double a = std::abs(f.first - g.first) / (std::abs(f.first) +
tol_)
341 + std::abs(f.second - g.second) / (std::abs(f.second) +
tol_);
343 return std::pow(a,
p_);
356 template<
template<
class>
class Func,
class Type >
364 func_diffn->set_param_from_func(func);
371 template<
template<
class>
class Func,
class Type >
374 interpolate_derivative(interpolate_derivative),
375 explicit_interpolant(NULL),
382 func_diffn->set_param_from_func(func);
399 template<
class TType>
401 : func_impl(&func_impl),
fix_(fix), fix_val(fix_val) {}
431 #endif //INTERPOLATION_IMPL_H FunctorBase< B< double > > * func_diff
Pointer to original functor with FADBAD B type.
double bound_b() const
Returns right boundary of the interval.
double a_div_step
bound_ divided by step - precomputed value for evaluation
unsigned int interval_miss_b
counts right misses of the interval
FuncError_wp1(Interpolant *interpolant, double p, double tol)
InterpolantImplicit()
constructor
Type operator()(Type u)
Virtual operator () with type Type.
Abstract templated implicit functor class.
void set_functor(Func< Type > *func, bool interpolate_derivative=false)
Sets the implicit functor.
unsigned int total_calls
counts total calls of evaluation
virtual double operator()(double x)
Virtual operator () with type Type.
double error()
Returns error of the interpolation.
double val_test(double x)
Do NOT use, only for testing purpose.
std::vector< double > df_vec
Vector of function derivatives values at nodes.
IFunctorBase< Type > * func_impl
FunctorBase< T< double > > * func_diffn
Pointer to original functor with FADBAD T type.
std::pair< double, double > DiffValue
FuncError_lp(Interpolant *interpolant, double p, double tol)
double f_val(double x)
Returns value of the original functor.
std::vector< double > f_vec
Vector of function values at nodes.
void set_functor(Func< Type > *func, bool interpolate_derivative=false)
Sets the functor.
double error_
Error of the interpolation.
unsigned int size() const
Returns the size of the interpolation table.
IFunctorBase< B< double > > * func_diff
Interpolant * explicit_interpolant
Interpolant * interpolant
double max
maximal x for which the evaluation was called outside the interval ((initially is equal the right bou...
DiffValue diff(double x)
Returns interpolated value of the derivation.
DiffValue diff_p1(double x)
Finds interval on which x lies.
FuncExplicit(IFunctorBase< TType > &func_impl, IFixVariable::Type fix, double fix_val)
double val_p1(double x)
Do NOT use, unless you are 100% sure.
Structure that keeps statistics of evaluation.
x variable will be fixed with given value
Abstract templated explicit functor class.
FunctorBase< double > * func
Pointer to original functor with double type.
DiffValue diff(double u)
Returns interpolated value of the derivation.
double val(double x)
Returns interpolated value.
double step
Chosen interpolation step.
std::vector< bool > checks
Vector of boolean values telling us which parameters are set or not.
EvalStatistics stats
Structure which keeps evaluation statistics. See InterpolantBase::eval_statistics.
Extrapolation::Type extrapolation
The main class for interpolation of functors.
IFunctorBase< T< double > > * func_diffn
virtual double operator()(double x)
Virtual operator () with type Type.
FuncExplicit()
Constructor.
double bound_a() const
Returns left boundary of the interval.
void set_param_from_func(FunctorCommon< TType > *func)
Sets a functor's parameters from another functor.
double bound_a_
Left interval boundary.
unsigned int interval_miss_a
counts left misses of the interval
double val(double u)
Returns interpolated value.
bool interpolate_derivative
Is true if we want to interpolate the derivative too.
DiffValue f_diff(double x)
Returns 1st derivative of original functor using FADBAD.
double bound_b_
Right interval boundary.
Interpolant()
Default constructor.
y variable will be fixed with given value
double min
minimal x for which the evaluation was called outside the interval (initially is equal the left bound...
Interpolant * interpolant
EvalStatistics statistics() const
Returns structure with evaluation statistics.
unsigned int size_
Number of dividing intervals.