Flow123d
JS_before_hm-2277-gb15131e45
|
Go to the documentation of this file.
18 #ifndef INTERPOLATION_H
19 #define INTERPOLATION_H
35 typedef std::pair<double,double>
DiffValue;
98 unsigned int size()
const;
304 template<
template<
class>
class Func,
class Type >
315 double val(
double x);
346 double f_val(
double x);
358 double f_diffn(
double x,
unsigned int n);
374 template<
template<
class>
class Func,
class Type >
442 template<
template<
class>
class Func,
class Type >
454 template<
template<
class>
class Func,
class Type >
471 double val(
double u);
487 double f_val(
double x,
double y);
492 double f_val(
double u);
505 double f_diffn(
double u,
unsigned int n);
521 template<
class Type=
double>
double val_test(double x)
Do NOT use, only for testing purpose.
double step
Chosen interpolation step.
EvalStatistics stats
Structure which keeps evaluation statistics. See InterpolantBase::eval_statistics.
void set_size(unsigned int size)
Sets size of the interpolation table. It is also equal to the number of intervals.
double f_val(double x, double y)
Returns interpolated value of the derivation.
const static double simpson_tolerance
Tolerance in Adaptive Simpson intergration.
double bound_a_
Left interval boundary.
double val(double u)
Returns interpolated value.
const static unsigned int n_derivatives
Defines how many derivatives we allow to be returned from Taylor's coeficients.
void set_functor(Func< Type > *func, bool interpolate_derivative=false)
Sets the implicit functor.
FunctorBase< T< double > > * func_diffn
Pointer to original functor with FADBAD T type.
double f_val(double x)
Returns value of the original functor.
virtual ~Interpolant(void)
Destructor.
std::vector< double > f_vec
Vector of function values at nodes.
long fact(long x)
Recursive factorial function (used in Taylor row expansion in n-th derivative computation).
double min
minimal x for which the evaluation was called outside the interval (initially is equal the left bound...
double f_diffn(double u, unsigned int n)
Interpolant()
Default constructor.
void set_functor(Func< Type > *func, bool interpolate_derivative=false)
Sets the functor.
FuncExplicit< double > * func_u
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.
std::vector< bool > checks
Vector of boolean values telling us which parameters are set or not.
static constexpr bool value
FunctorBase< B< double > > * func_diff
Pointer to original functor with FADBAD B type.
unsigned int size_
Number of dividing intervals.
bool interpolate_derivative
Is true if we want to interpolate the derivative too.
double f_diffn(double x, unsigned int n)
double a_div_step
bound_ divided by step - precomputed value for evaluation
The main class for interpolation of functors.
FunctorBase< double > * func
Pointer to original functor with double type.
Abstract templated implicit functor class.
void compute_values()
Creates table of nodes and function values.
double error_
Error of the interpolation.
virtual int interpolate()=0
Creates piecewise polynomial interpolation.
enum InterpolantBase::Check::@20 Type
Enumerates parameters that must be set before creation of the interpolant.
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.
virtual ~InterpolantImplicit(void)
destructor
unsigned int interval_miss_a
counts left misses of the interval
unsigned int interval_miss_b
counts right misses of the interval
unsigned int total_calls
counts total calls of evaluation
virtual int interpolate()
Creates piecewise interpolation with polynomials of selected degree.
void interpolate_p1()
Creates piecewise linear interpolation.
void check_stats_and_reinterpolate(double percentage=0.3)
Can be called to check automatically the evaluation statistics and possibly reinterpolate.
@ fix_x
x variable will be fixed with given value
@ no_fix
no variable is fixed (used when InterpolantImplicit is created)
std::vector< double > df_vec
Vector of function derivatives values at nodes.
ErrorNorm::Type norm_type
Type of norm used to compute error of the interpolation.
Interpolant * explicit_interpolant
DiffValue diff_p1(double x)
Finds interval on which x lies.
Structure that keeps statistics of evaluation.
unsigned int max_size
Maximal size of the interpolation table.
Base class for interpolation.
void reset_stat()
Resets all measured statistics.
const static unsigned int default_max_size
Default maximal size of the interpolation table.
IFunctorBase< double > * func
void compute_error(double tol, std::vector< double > &f, std::vector< double > &df)
Creates piecewise linear interpolation.
double val_p1(double x)
Do NOT use, unless you are 100% sure.
@ fix_y
y variable will be fixed with given value
virtual ~InterpolantBase()
Destructor.
bool interpolate_derivative
Is true if we want to interpolate the derivative too.
bool automatic_size
Is true if step/size should be chosen automatically.
std::pair< double, double > DiffValue
DiffValue diff(double x)
Returns interpolated value of the derivation.
DiffValue f_diff(double x)
Returns 1st derivative of original functor using FADBAD.
double bound_a() const
Returns left boundary of the interval.
double user_tol
User set tolerance which is used during automatic step choice.
void swap_middle_values(std::vector< double > &f, std::vector< double > &df)
Extrapolation::Type extrapolation
DiffValue f_diff(double x, double y)
Returns 1st derivative of original functor using FADBAD.
double max
maximal x for which the evaluation was called outside the interval ((initially is equal the right bou...
void set_interval(double bound_a, double bound_b)
Sets the interpolation interval boundaries.
void check_all()
Checks that the parameters are set before interpolation.
unsigned int size() const
Returns the size of the interpolation table.
Abstract templated explicit functor class.
IFunctorBase< T< double > > * func_diffn
InterpolantBase()
Default constructor.
void set_extrapolation(Extrapolation::Type extrapolation)
Sets the type of extrapolation. Functor type is default.
double val(double x)
Returns interpolated value.
double bound_b() const
Returns right boundary of the interval.
double bound_b_
Right interval boundary.
InterpolantImplicit()
constructor
unsigned int n_nodes
Number of nodes in the interval .
EvalStatistics statistics() const
Returns structure with evaluation statistics.
DiffValue diff(double u)
Returns interpolated value of the derivation.
IFunctorBase< B< double > > * func_diff
double p
Exponent used in norms and when computing error.
double error()
Returns error of the interpolation.
void fix_variable(IFixVariable::Type fix, double value)
virtual int interpolate()
Creates piecewise interpolation with polynomials of selected degree.