35 max_size(default_max_size),
36 automatic_size(false),
69 ASSERT_GT(
size, 0).error(
"Size of interpolation table must be positive number!.");
85 ASSERT_GT(init_size, 0).error(
"Maximal size of interpolation table must be positive number!.");
86 ASSERT_GE(
max_size, init_size).error(
"Maximal size of interpolation table is smaller than initial size.");
115 bool reinterpolate =
false;
119 reinterpolate =
true;
124 reinterpolate =
true;
129 MessageOut() <<
"Interpolation: Reinterpolating...\n";
160 interpolate_derivative(false)
183 f[i] = f[i] * this->
fact(i);
192 unsigned int result = 10;
239 MessageOut().fmt(
"Interpolation: Size of the table set automaticaly to: {} after {} cycles.\n",
size_, k);
258 WarningOut().fmt(
"Interpolation: User defined tolerance {} has not been satisfied with size of interpolation table {}).\n",
275 MessageOut().fmt(
"Interpolation: Interpolation error estimate is: {}.\n",
error_);
350 for(
unsigned int i = 0; i <
size_; i++)
365 for(
unsigned int i = 0; i <
size_; i++)
377 double new_size = 2*
size_;
387 for(
unsigned int i=0; i!=
size_; i++)
389 swap_f_vec.push_back(
f_vec[i]);
390 swap_f_vec.push_back(f[i]);
392 swap_f_vec.push_back(
f_vec.back());
398 for(
unsigned int i=0; i!=
size_; i++)
400 swap_df_vec.push_back(
df_vec[i]);
401 swap_df_vec.push_back(df[i]);
403 swap_df_vec.push_back(
df_vec.back());
418 double temp_x = temp_a;
426 for(
unsigned int i = 0; i !=
size_; i++)
428 temp_x = temp_a +
step*i;
430 f.push_back(
value.first);
431 df.push_back(
value.second);
435 tot_err = std::max( tot_err,
436 std::abs(
value.first - int_value.first) / (std::abs(
value.first) + tol)
437 + std::abs(
value.second - int_value.second) / (std::abs(
value.second) + tol)
444 for(
unsigned int i = 0; i !=
size_; i++)
446 temp_x = temp_a +
step*i;
447 f.push_back(
f_val(temp_x));
448 tot_err = std::max( tot_err,
449 std::abs(f.back() -
val_p1(temp_x)) / (std::abs(f.back()) + tol)
518 for(
unsigned long i = 0; i <
size_; i++ )
529 tot_err = std::pow(tot_err, 1.0/exponent);
543 interpolate_derivative(false),
544 explicit_interpolant(NULL),
566 return func_u->operator()(u);
#define ASSERT_PERMANENT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
#define ASSERT_LT(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
#define ASSERT_GE(a, b)
Definition of comparative assert macro (Greater or Equal) only for debug mode.
#define ASSERT_GT(a, b)
Definition of comparative assert macro (Greater Than) only for debug mode.
#define ASSERT_LE(a, b)
Definition of comparative assert macro (Less or Equal) only for debug mode.
static double AdaptSimpson(FunctorBase< double > &func, const double &a, const double &b, const double &tol)
main method that starts the evaluation and calls the recursion
Base class for interpolation.
double p
Exponent used in norms and when computing error.
unsigned int size() const
Returns the size of the interpolation table.
virtual ~InterpolantBase()
Destructor.
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 bound_a() const
Returns left boundary of the interval.
double bound_b_
Right interval boundary.
void check_stats_and_reinterpolate(double percentage=0.3)
Can be called to check automatically the evaluation statistics and possibly reinterpolate.
InterpolantBase()
Default constructor.
void check_all()
Checks that the parameters are set before interpolation.
static const double simpson_tolerance
Tolerance in Adaptive Simpson intergration.
unsigned int max_size
Maximal size of the interpolation table.
double bound_b() const
Returns right boundary of the interval.
double step
Chosen interpolation step.
void reset_stat()
Resets all measured statistics.
std::vector< bool > checks
Vector of boolean values telling us which parameters are set or not.
void set_size(unsigned int size)
Sets size of the interpolation table. It is also equal to the number of intervals.
double error_
Error of the interpolation.
double user_tol
User set tolerance which is used during automatic step choice.
virtual int interpolate()=0
Creates piecewise polynomial interpolation.
ErrorNorm::Type norm_type
Type of norm used to compute error of the interpolation.
long fact(long x)
Recursive factorial function (used in Taylor row expansion in n-th derivative computation).
static const unsigned int default_max_size
Default maximal size of the interpolation table.
void set_extrapolation(Extrapolation::Type extrapolation)
Sets the type of extrapolation. Functor type is default.
double error()
Returns error of the interpolation.
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.
Extrapolation::Type extrapolation
void set_interval(double bound_a, double bound_b)
Sets the interpolation interval boundaries.
static const unsigned int n_derivatives
Defines how many derivatives we allow to be returned from Taylor's coeficients.
double bound_a_
Left interval boundary.
unsigned int n_nodes
Number of nodes in the interval .
unsigned int size_
Number of dividing intervals.
bool automatic_size
Is true if step/size should be chosen automatically.
double a_div_step
bound_ divided by step - precomputed value for evaluation
EvalStatistics stats
Structure which keeps evaluation statistics. See InterpolantBase::eval_statistics.
IFunctorBase< B< double > > * func_diff
virtual ~InterpolantImplicit(void)
destructor
InterpolantImplicit()
constructor
void fix_variable(IFixVariable::Type fix, double value)
void interpolate_p1()
Creates piecewise linear interpolation.
double f_val(double x, double y)
Returns interpolated value of the derivation.
Interpolant * explicit_interpolant
IFunctorBase< double > * func
IFunctorBase< T< double > > * func_diffn
virtual int interpolate()
Creates piecewise interpolation with polynomials of selected degree.
double val(double u)
Returns interpolated value.
FuncExplicit< double > * func_u
void swap_middle_values(std::vector< double > &f, std::vector< double > &df)
void compute_error(double tol, std::vector< double > &f, std::vector< double > &df)
Creates piecewise linear interpolation.
virtual int interpolate()
Creates piecewise interpolation with polynomials of selected degree.
FunctorBase< T< double > > * func_diffn
Pointer to original functor with FADBAD T type.
std::vector< double > f_vec
Vector of function values at nodes.
FunctorBase< B< double > > * func_diff
Pointer to original functor with FADBAD B type.
DiffValue diff_p1(double x)
Finds interval on which x lies.
double f_val(double x)
Returns value of the original functor.
virtual ~Interpolant(void)
Destructor.
void compute_values()
Creates table of nodes and function values.
std::vector< double > df_vec
Vector of function derivatives values at nodes.
bool interpolate_derivative
Is true if we want to interpolate the derivative too.
double val_p1(double x)
Do NOT use, unless you are 100% sure.
Interpolant()
Default constructor.
DiffValue f_diff(double x)
Returns 1st derivative of original functor using FADBAD.
double f_diffn(double x, unsigned int n)
std::pair< double, double > DiffValue
static constexpr bool value
#define WarningOut()
Macro defining 'warning' record of log.
#define MessageOut()
Macro defining 'message' record of log.
#define DebugOut()
Macro defining 'debug' record of log.
double max
maximal x for which the evaluation was called outside the interval ((initially is equal the right bou...
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
double min
minimal x for which the evaluation was called outside the interval (initially is equal the left bound...