Flow123d
release_2.2.0-26-ge868538
|
Base class for interpolation. More...
#include <interpolant.hh>
Classes | |
struct | Check |
struct | EvalStatistics |
Structure that keeps statistics of evaluation. More... | |
Public Member Functions | |
InterpolantBase () | |
Default constructor. More... | |
virtual | ~InterpolantBase () |
Destructor. More... | |
Interpolation. | |
double | error () |
Returns error of the interpolation. More... | |
double | bound_a () const |
Returns left boundary of the interval. More... | |
double | bound_b () const |
Returns right boundary of the interval. More... | |
unsigned int | size () const |
Returns the size of the interpolation table. More... | |
void | set_interval (double bound_a, double bound_b) |
Sets the interpolation interval boundaries. More... | |
void | set_size (unsigned int size) |
Sets size of the interpolation table. It is also equal to the number of intervals. More... | |
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. More... | |
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. More... | |
void | set_extrapolation (Extrapolation::Type extrapolation) |
Sets the type of extrapolation. Functor type is default. More... | |
virtual int | interpolate ()=0 |
Creates piecewise polynomial interpolation. More... | |
Evaluation statistics. | |
These members are used recording the statistics of the evaluation. | |
EvalStatistics | statistics () const |
Returns structure with evaluation statistics. More... | |
void | reset_stat () |
Resets all measured statistics. More... | |
void | check_stats_and_reinterpolate (double percentage=0.3) |
Can be called to check automatically the evaluation statistics and possibly reinterpolate. More... | |
Protected Member Functions | |
long | fact (long x) |
Recursive factorial function (used in Taylor row expansion in n-th derivative computation). More... | |
Protected Attributes | |
double | bound_a_ |
Left interval boundary. More... | |
double | bound_b_ |
Right interval boundary. More... | |
double | step |
Chosen interpolation step. More... | |
double | a_div_step |
bound_ divided by step - precomputed value for evaluation More... | |
unsigned int | size_ |
Number of dividing intervals. More... | |
unsigned int | n_nodes |
Number of nodes in the interval . More... | |
double | user_tol |
User set tolerance which is used during automatic step choice. More... | |
unsigned int | max_size |
Maximal size of the interpolation table. More... | |
bool | automatic_size |
Is true if step/size should be chosen automatically. More... | |
ErrorNorm::Type | norm_type |
Type of norm used to compute error of the interpolation. More... | |
double | p |
Exponent used in norms and when computing error. More... | |
double | error_ |
Error of the interpolation. More... | |
Extrapolation::Type | extrapolation |
EvalStatistics | stats |
Structure which keeps evaluation statistics. See InterpolantBase::eval_statistics. More... | |
Static Protected Attributes | |
static const unsigned int | n_derivatives = 10 |
Defines how many derivatives we allow to be returned from Taylor's coeficients. More... | |
static const unsigned int | default_max_size = 10*1000 |
Default maximal size of the interpolation table. More... | |
static const double | simpson_tolerance = 1e-10 |
Tolerance in Adaptive Simpson intergration. More... | |
Internal check system. | |
This is internal check system which checks the values of parameters before making interpolation. | |
std::vector< bool > | checks |
Vector of boolean values telling us which parameters are set or not. More... | |
void | check_all () |
Checks that the parameters are set before interpolation. More... | |
Base class for interpolation.
This class serves as the common interface for interpolation classes. It provides functions for setting the common parameters of an interpolation such as interval, size of the table and extrapolation.
Definition at line 73 of file interpolant.hh.
InterpolantBase::InterpolantBase | ( | ) |
Default constructor.
Definition at line 32 of file interpolant.cc.
|
virtual |
Destructor.
Definition at line 46 of file interpolant.cc.
|
inline |
Returns left boundary of the interval.
Definition at line 37 of file interpolant_impl.hh.
|
inline |
Returns right boundary of the interval.
Definition at line 42 of file interpolant_impl.hh.
|
protected |
Checks that the parameters are set before interpolation.
Definition at line 136 of file interpolant.cc.
void InterpolantBase::check_stats_and_reinterpolate | ( | double | percentage = 0.3 | ) |
Can be called to check automatically the evaluation statistics and possibly reinterpolate.
The function computes ratio of evaluations outside the interpolation interval - on each side of the interval. Then it compares the results with given percentage and accordingly changes (only streches) the interval and reinterpolate.
percentage | is the percentage of evaluations outside the interval (on one side) |
Definition at line 113 of file interpolant.cc.
|
inline |
Returns error of the interpolation.
It is equal to the chosen norm of the difference divided by the lenght of interval. Returns -1.0 if the interpolation has not been computed yet.
Definition at line 27 of file interpolant_impl.hh.
|
protected |
Recursive factorial function (used in Taylor row expansion in n-th derivative computation).
Definition at line 145 of file interpolant.cc.
|
pure virtual |
Creates piecewise polynomial interpolation.
Implemented in InterpolantImplicit, and Interpolant.
void InterpolantBase::reset_stat | ( | ) |
Resets all measured statistics.
Definition at line 100 of file interpolant.cc.
void InterpolantBase::set_extrapolation | ( | Extrapolation::Type | extrapolation | ) |
Sets the type of extrapolation. Functor type is default.
extrapolation | is the type of extrapolation (defined by enumeration ExtrapolationType ) |
Definition at line 95 of file interpolant.cc.
void InterpolantBase::set_interval | ( | double | bound_a, |
double | bound_b | ||
) |
Sets the interpolation interval boundaries.
bound_a | is the left boundary of the interval |
bound_b | is the right boundary of the interval |
Definition at line 50 of file interpolant.cc.
void InterpolantBase::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.
norm_type | is the type of norm in which the error of interpolation is computed |
p | is the exponent used in norms and |
Definition at line 76 of file interpolant.cc.
void InterpolantBase::set_size | ( | unsigned int | size | ) |
Sets size of the interpolation table. It is also equal to the number of intervals.
size | is the new size of the interpolation table |
Definition at line 67 of file interpolant.cc.
void InterpolantBase::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.
When interpolate
is called than the size is increased (by smaller interval dividing) until the given tolerance or the maximum size of the interpolation table is reached.
user_tol | is the tolerance which should the interpolation meet |
init_size | is the initial choice of table size |
max_size | is maximal size of the table that user allows |
Definition at line 83 of file interpolant.cc.
|
inline |
Returns the size of the interpolation table.
Definition at line 47 of file interpolant_impl.hh.
|
inline |
Returns structure with evaluation statistics.
Definition at line 32 of file interpolant_impl.hh.
|
protected |
bound_ divided by step - precomputed value for evaluation
Definition at line 162 of file interpolant.hh.
|
protected |
Is true if step/size should be chosen automatically.
Definition at line 172 of file interpolant.hh.
|
protected |
Left interval boundary.
Definition at line 162 of file interpolant.hh.
|
protected |
Right interval boundary.
Definition at line 162 of file interpolant.hh.
|
protected |
Vector of boolean values telling us which parameters are set or not.
Definition at line 201 of file interpolant.hh.
|
staticprotected |
Default maximal size of the interpolation table.
Definition at line 185 of file interpolant.hh.
|
protected |
Error of the interpolation.
Definition at line 176 of file interpolant.hh.
|
protected |
Extrapolation type - 'what' is evaluated outside the interpolation interval. Default value after interpolant construction is InterpolantBase::functor.
Definition at line 181 of file interpolant.hh.
|
protected |
Maximal size of the interpolation table.
Definition at line 171 of file interpolant.hh.
|
staticprotected |
Defines how many derivatives we allow to be returned from Taylor's coeficients.
Definition at line 184 of file interpolant.hh.
|
protected |
Number of nodes in the interval .
Definition at line 167 of file interpolant.hh.
|
protected |
Type of norm used to compute error of the interpolation.
Definition at line 173 of file interpolant.hh.
|
protected |
Exponent used in norms and when computing error.
Definition at line 174 of file interpolant.hh.
|
staticprotected |
Tolerance in Adaptive Simpson intergration.
Definition at line 186 of file interpolant.hh.
|
protected |
Number of dividing intervals.
Definition at line 167 of file interpolant.hh.
|
protected |
Structure which keeps evaluation statistics. See InterpolantBase::eval_statistics.
Definition at line 209 of file interpolant.hh.
|
protected |
Chosen interpolation step.
Definition at line 162 of file interpolant.hh.
|
protected |
User set tolerance which is used during automatic step choice.
Definition at line 170 of file interpolant.hh.