Medusa  1.1
Coordinate Free Mehless Method implementation
mm::SheppardInterpolant< vec_t, value_t > Class Template Reference

#include <Sheppard_fwd.hpp>

Detailed Description

template<class vec_t, class value_t>
class mm::SheppardInterpolant< vec_t, value_t >

Scattered interpolant using a slightly modified Sheppard's interpolation (inverse distance weighting).

The essential difference is the introduction of a "regularization" parameter (reg) that is used when computing the inverse distance weights: \( w_i = 1 / (d(x, x_i)^{power} + reg) \) By supplying a positive regularization parameter one can avoid singularities at the locations of the data points as well as control the "smoothness" of the interpolation (e.g., make the weights of the neighbors less varied). The "smoothness" of interpolation can also be controlled by the power parameter (power). The interpolation is not continuous due to the cut off at the closest neighbors.

See also
PUApproximant

Usage example:

int N = 4; // Number of points.
int num_closest = 2; // Closest neighbors.
Range<Vec1d> pos(N); // Positions.
Range<double> values(N); // Values.
for (int i = 0; i < N; i++) {
pos[i] = i;
values[i] = i;
}
// Sheppard's Interpolation.
SheppardInterpolant<Vec1d, double> interpolant(pos, values);
Vec1d point;
point.setConstant(1.5);
// Interpolated value.
double value = interpolant(point, num_closest);

Definition at line 36 of file Sheppard_fwd.hpp.

+ Collaboration diagram for mm::SheppardInterpolant< vec_t, value_t >:

Public Member Functions

 SheppardInterpolant ()=default
 Construct a new empty Sheppard Interpolant object. More...
 
 SheppardInterpolant (const Range< vec_t > &pos)
 Construct a new Sheppard Interpolant. More...
 
 SheppardInterpolant (const Range< vec_t > &pos, const Range< value_t > &values)
 Construct a new Sheppard Interpolant object. More...
 
template<typename values_container_t >
void setValues (const values_container_t &new_values)
 Set new values. More...
 
void setPositions (const Range< vec_t > &pos)
 Set new positions. More...
 
value_t operator() (const vec_t &point, int num_closest, int power=2, double reg=0.0, double conf_dist=1e-12) const
 Evaluate the interpolant at the given point. More...
 

Private Types

typedef vec_t::scalar_t scalar_t
 Scalar data type. More...
 

Private Attributes

KDTree< vec_t > tree
 Tree of all points. More...
 
Range< value_t > values
 Function values at given points. More...
 

Constructor & Destructor Documentation

◆ SheppardInterpolant() [1/3]

template<class vec_t , class value_t >
mm::SheppardInterpolant< vec_t, value_t >::SheppardInterpolant ( )
default

Construct a new empty Sheppard Interpolant object.

Use setValues and setPositions() to fill the object.

◆ SheppardInterpolant() [2/3]

template<class vec_t , class value_t >
mm::SheppardInterpolant< vec_t, value_t >::SheppardInterpolant ( const Range< vec_t > &  pos)
inlineexplicit

Construct a new Sheppard Interpolant.

Use setValues to add values.

Parameters
posPositions.

Definition at line 53 of file Sheppard_fwd.hpp.

◆ SheppardInterpolant() [3/3]

template<class vec_t , class value_t >
mm::SheppardInterpolant< vec_t, value_t >::SheppardInterpolant ( const Range< vec_t > &  pos,
const Range< value_t > &  values 
)
inline

Construct a new Sheppard Interpolant object.

Parameters
posInitial positions.
valuesFunction values to be interpolated..

Definition at line 63 of file Sheppard_fwd.hpp.

Member Function Documentation

◆ operator()()

template<class vec_t , class value_t >
value_t mm::SheppardInterpolant< vec_t, value_t >::operator() ( const vec_t &  point,
int  num_closest,
int  power = 2,
double  reg = 0.0,
double  conf_dist = 1e-12 
) const

Evaluate the interpolant at the given point.

The complexity of the evaluation function is \( \mathcal{O}(m\log{n}) \) for \( m \) closest nodes and \( n \) positions in the k-d tree.

The approximation order equals \( O(h) \).

Parameters
pointLocation where evaluation is needed.
num_closestNumber of closest neighbors.
powerThe power of the inverse distance used for the interpolation weights.
regRegularization parameter.
conf_distThe confusion distance below which the interpolator should use the value of the closest data point instead of attempting to interpolate.
Returns
value_t Interpolation value.

Definition at line 17 of file Sheppard.hpp.

◆ setPositions()

template<class vec_t , class value_t >
void mm::SheppardInterpolant< vec_t, value_t >::setPositions ( const Range< vec_t > &  pos)
inline

Set new positions.

Definition at line 85 of file Sheppard_fwd.hpp.

◆ setValues()

template<class vec_t , class value_t >
template<typename values_container_t >
void mm::SheppardInterpolant< vec_t, value_t >::setValues ( const values_container_t &  new_values)
inline

Set new values.

Any container that supports forward iteration with .begin() and .end() can be used. The contained element type must be compatible with value_t.

Definition at line 80 of file Sheppard_fwd.hpp.

Member Data Documentation

◆ tree

template<class vec_t , class value_t >
KDTree<vec_t> mm::SheppardInterpolant< vec_t, value_t >::tree
private

Tree of all points.

Definition at line 38 of file Sheppard_fwd.hpp.

◆ values

template<class vec_t , class value_t >
Range<value_t> mm::SheppardInterpolant< vec_t, value_t >::values
private

Function values at given points.

Definition at line 39 of file Sheppard_fwd.hpp.


The documentation for this class was generated from the following files:
mm::SheppardInterpolant::values
Range< value_t > values
Function values at given points.
Definition: Sheppard_fwd.hpp:39
mm::Vec1d
Vec< double, 1 > Vec1d
Convenience typedef for 1d vector of doubles.
Definition: Vec_fwd.hpp:33