Flow123d  JS_before_hm-1755-g6249b9fc1
Classes | Public Member Functions | List of all members
InterpolantBase Class Referenceabstract

Base class for interpolation. More...

#include <interpolant.hh>

Inheritance diagram for InterpolantBase:
Inheritance graph
[legend]
Collaboration diagram for InterpolantBase:
Collaboration graph
[legend]

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.

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 $(a,b)$. 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 $ L_p $ and $ W_p^1 $ when computing error. More...
 
double error_
 Error of the interpolation. More...
 
Extrapolation::Type extrapolation
 
const static unsigned int n_derivatives = 10
 Defines how many derivatives we allow to be returned from Taylor's coeficients. More...
 
const static unsigned int default_max_size = 10*1000
 Default maximal size of the interpolation table. More...
 
const static double simpson_tolerance = 1e-10
 Tolerance in Adaptive Simpson intergration. More...
 
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...
 
long fact (long x)
 Recursive factorial function (used in Taylor row expansion in n-th derivative computation). 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...
 
EvalStatistics stats
 Structure which keeps evaluation statistics. See InterpolantBase::eval_statistics. More...
 
void check_all ()
 Checks that the parameters are set before interpolation. More...
 

Detailed Description

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.

See also
Interpolant
InterpolantImplicit

Definition at line 78 of file interpolant.hh.

Constructor & Destructor Documentation

◆ InterpolantBase()

InterpolantBase::InterpolantBase ( )

Default constructor.

Definition at line 32 of file interpolant.cc.

◆ ~InterpolantBase()

InterpolantBase::~InterpolantBase ( )
virtual

Destructor.

Definition at line 46 of file interpolant.cc.

Member Function Documentation

◆ bound_a()

double InterpolantBase::bound_a ( ) const
inline

Returns left boundary of the interval.

Definition at line 37 of file interpolant_impl.hh.

Here is the caller graph for this function:

◆ bound_b()

double InterpolantBase::bound_b ( ) const
inline

Returns right boundary of the interval.

Definition at line 42 of file interpolant_impl.hh.

Here is the caller graph for this function:

◆ check_all()

void InterpolantBase::check_all ( )
protected

Checks that the parameters are set before interpolation.

Definition at line 136 of file interpolant.cc.

Here is the caller graph for this function:

◆ check_stats_and_reinterpolate()

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.

Parameters
percentageis the percentage of evaluations outside the interval (on one side)

Definition at line 113 of file interpolant.cc.

◆ error()

double InterpolantBase::error ( )
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.

◆ fact()

long InterpolantBase::fact ( long  x)
protected

Recursive factorial function (used in Taylor row expansion in n-th derivative computation).

Definition at line 145 of file interpolant.cc.

Here is the caller graph for this function:

◆ interpolate()

virtual int InterpolantBase::interpolate ( )
pure virtual

Creates piecewise polynomial interpolation.

Returns
  • 0 if interpolation has been created
  • 1 if the tolerance has not been satisfied (in case of automatic choice of size)

Implemented in InterpolantImplicit, and Interpolant.

Here is the caller graph for this function:

◆ reset_stat()

void InterpolantBase::reset_stat ( )

Resets all measured statistics.

Definition at line 100 of file interpolant.cc.

Here is the caller graph for this function:

◆ set_extrapolation()

void InterpolantBase::set_extrapolation ( Extrapolation::Type  extrapolation)

Sets the type of extrapolation. Functor type is default.

Parameters
extrapolationis the type of extrapolation (defined by enumeration ExtrapolationType)

Definition at line 95 of file interpolant.cc.

◆ set_interval()

void InterpolantBase::set_interval ( double  bound_a,
double  bound_b 
)

Sets the interpolation interval boundaries.

Parameters
bound_ais the left boundary of the interval
bound_bis the right boundary of the interval

Definition at line 50 of file interpolant.cc.

◆ set_norm()

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.

Parameters
norm_typeis the type of norm in which the error of interpolation is computed
pis the exponent used in norms $ L_p $ and $ W_p^1 $

Definition at line 76 of file interpolant.cc.

◆ set_size()

void InterpolantBase::set_size ( unsigned int  size)

Sets size of the interpolation table. It is also equal to the number of intervals.

Parameters
sizeis the new size of the interpolation table

Definition at line 67 of file interpolant.cc.

◆ set_size_automatic()

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.

Parameters
user_tolis the tolerance which should the interpolation meet
init_sizeis the initial choice of table size
max_sizeis maximal size of the table that user allows

Definition at line 83 of file interpolant.cc.

◆ size()

unsigned int InterpolantBase::size ( ) const
inline

Returns the size of the interpolation table.

Definition at line 47 of file interpolant_impl.hh.

Here is the caller graph for this function:

◆ statistics()

InterpolantBase::EvalStatistics InterpolantBase::statistics ( ) const
inline

Returns structure with evaluation statistics.

Definition at line 32 of file interpolant_impl.hh.

Member Data Documentation

◆ a_div_step

double InterpolantBase::a_div_step
protected

bound_ divided by step - precomputed value for evaluation

Definition at line 170 of file interpolant.hh.

◆ automatic_size

bool InterpolantBase::automatic_size
protected

Is true if step/size should be chosen automatically.

Definition at line 177 of file interpolant.hh.

◆ bound_a_

double InterpolantBase::bound_a_
protected

Left interval boundary.

Definition at line 167 of file interpolant.hh.

◆ bound_b_

double InterpolantBase::bound_b_
protected

Right interval boundary.

Definition at line 168 of file interpolant.hh.

◆ checks

std::vector<bool> InterpolantBase::checks
protected

Vector of boolean values telling us which parameters are set or not.

Definition at line 206 of file interpolant.hh.

◆ default_max_size

const unsigned int InterpolantBase::default_max_size = 10*1000
staticprotected

Default maximal size of the interpolation table.

Definition at line 190 of file interpolant.hh.

◆ error_

double InterpolantBase::error_
protected

Error of the interpolation.

Definition at line 181 of file interpolant.hh.

◆ extrapolation

Extrapolation::Type InterpolantBase::extrapolation
protected

Extrapolation type - 'what' is evaluated outside the interpolation interval. Default value after interpolant construction is InterpolantBase::functor.

Definition at line 186 of file interpolant.hh.

◆ max_size

unsigned int InterpolantBase::max_size
protected

Maximal size of the interpolation table.

Definition at line 176 of file interpolant.hh.

◆ n_derivatives

const unsigned int InterpolantBase::n_derivatives = 10
staticprotected

Defines how many derivatives we allow to be returned from Taylor's coeficients.

Definition at line 189 of file interpolant.hh.

◆ n_nodes

unsigned int InterpolantBase::n_nodes
protected

Number of nodes in the interval $(a,b)$.

Definition at line 173 of file interpolant.hh.

◆ norm_type

ErrorNorm::Type InterpolantBase::norm_type
protected

Type of norm used to compute error of the interpolation.

Definition at line 178 of file interpolant.hh.

◆ p

double InterpolantBase::p
protected

Exponent used in norms $ L_p $ and $ W_p^1 $ when computing error.

Definition at line 179 of file interpolant.hh.

◆ simpson_tolerance

const double InterpolantBase::simpson_tolerance = 1e-10
staticprotected

Tolerance in Adaptive Simpson intergration.

See also
AdaptiveSimpson

Definition at line 191 of file interpolant.hh.

◆ size_

unsigned int InterpolantBase::size_
protected

Number of dividing intervals.

Definition at line 172 of file interpolant.hh.

◆ stats

EvalStatistics InterpolantBase::stats
protected

Structure which keeps evaluation statistics. See InterpolantBase::eval_statistics.

Definition at line 214 of file interpolant.hh.

◆ step

double InterpolantBase::step
protected

Chosen interpolation step.

Definition at line 169 of file interpolant.hh.

◆ user_tol

double InterpolantBase::user_tol
protected

User set tolerance which is used during automatic step choice.

Definition at line 175 of file interpolant.hh.


The documentation for this class was generated from the following files: