1 #ifndef INTERPOLATION_H
2 #define INTERPOLATION_H
76 unsigned int size()
const;
123 unsigned int interval_miss_a,
282 template<
template<
class>
class Func,
class Type >
293 double val(
double x);
324 double f_val(
double x);
336 double f_diffn(
double x,
unsigned int n);
352 template<
template<
class>
class Func,
class Type >
420 template<
template<
class>
class Func,
class Type >
432 template<
template<
class>
class Func,
class Type >
449 double val(
double u);
465 double f_val(
double x,
double y);
470 double f_val(
double u);
483 double f_diffn(
double u,
unsigned int n);
499 template<
class Type=
double>
FunctorBase< B< double > > * func_diff
Pointer to original functor with FADBAD B type.
bool automatic_size
Is true if step/size should be chosen automatically.
ErrorNorm::Type norm_type
Type of norm used to compute error of the interpolation.
DiffValue f_diff(double x, double y)
Returns 1st derivative of original functor using FADBAD.
enum InterpolantBase::Check::@1 Type
Enumerates parameters that must be set before creation of the interpolant.
double bound_b() const
Returns right boundary of the interval.
void compute_values()
Creates table of nodes and function values.
double a_div_step
bound_ divided by step - precomputed value for evaluation
double f_diffn(double x, unsigned int n)
static const double simpson_tolerance
Tolerance in Adaptive Simpson intergration.
bool interpolate_derivative
Is true if we want to interpolate the derivative too.
unsigned int n_nodes
Number of nodes in the interval .
static const unsigned int default_max_size
Default maximal size of the interpolation table.
InterpolantImplicit()
constructor
void check_stats_and_reinterpolate(double percentage=0.3)
Can be called to check automatically the evaluation statistics and possibly reinterpolate.
void set_interval(double bound_a, double bound_b)
Sets the interpolation interval boundaries.
virtual ~InterpolantBase()
Destructor.
void fix_variable(IFixVariable::Type fix, double value)
void set_functor(Func< Type > *func, bool interpolate_derivative=false)
Sets the implicit functor.
unsigned int total_calls
counts total calls of evaluation
double user_tol
User set tolerance which is used during automatic step choice.
no variable is fixed (used when InterpolantImplicit is created)
InterpolantBase()
Default constructor.
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.
FunctorBase< T< double > > * func_diffn
Pointer to original functor with FADBAD T type.
std::pair< double, double > DiffValue
void compute_error(double tol, std::vector< double > &f, std::vector< double > &df)
Creates piecewise linear interpolation.
double f_val(double x)
Returns value of the original functor.
Base class for interpolation.
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.
virtual int interpolate()=0
Creates piecewise polynomial interpolation.
unsigned int size() const
Returns the size of the interpolation table.
IFunctorBase< B< double > > * func_diff
Interpolant * explicit_interpolant
virtual ~InterpolantImplicit(void)
destructor
DiffValue diff(double x)
Returns interpolated value of the derivation.
DiffValue diff_p1(double x)
Finds interval on which x lies.
long fact(long x)
Recursive factorial function (used in Taylor row expansion in n-th derivative computation).
void set_size_automatic(double user_tol, unsigned int init_size, unsigned int max_size=default_max_size)
Sets automatic choice of the size of the table.
double val_p1(double x)
Do NOT use, unless you are 100% sure.
Structure that keeps statistics of evaluation.
unsigned int max_size
Maximal size of the interpolation table.
x variable will be fixed with given value
double f_diffn(double u, unsigned int n)
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.
void set_size(unsigned int size)
Sets size of the interpolation table. It is also equal to the number of intervals.
void set_norm(ErrorNorm::Type norm_type=ErrorNorm::max, double p=2)
Sets the type of norm used for computing estimate of the error of the interpolation.
double f_val(double x, double y)
Returns interpolated value of the derivation.
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.
void interpolate_p1()
Creates piecewise linear interpolation.
void set_extrapolation(Extrapolation::Type extrapolation)
Sets the type of extrapolation. Functor type is default.
IFunctorBase< T< double > > * func_diffn
virtual int interpolate()
Creates piecewise interpolation with polynomials of selected degree.
virtual int interpolate()
Creates piecewise interpolation with polynomials of selected degree.
double bound_a() const
Returns left boundary of the interval.
IFunctorBase< double > * func
double bound_a_
Left interval boundary.
double val(double u)
Returns interpolated value.
FuncExplicit< double > * func_u
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.
void check_all()
Checks that the parameters are set before interpolation.
static const unsigned int n_derivatives
Defines how many derivatives we allow to be returned from Taylor's coeficients.
Interpolant()
Default constructor.
y variable will be fixed with given value
double p
Exponent used in norms and when computing error.
double min
minimal x for which the evaluation was called outside the interval (initially is equal the left bound...
virtual ~Interpolant(void)
Destructor.
void swap_middle_values(std::vector< double > &f, std::vector< double > &df)
void reset_stat()
Resets all measured statistics.
EvalStatistics statistics() const
Returns structure with evaluation statistics.
unsigned int size_
Number of dividing intervals.