Medusa  1.1
Coordinate Free Mehless Method implementation
Sheppard_fwd.hpp
Go to the documentation of this file.
1 #ifndef MEDUSA_BITS_INTERPOLANTS_SHEPPARD_FWD_HPP_
2 #define MEDUSA_BITS_INTERPOLANTS_SHEPPARD_FWD_HPP_
3 
13 
14 namespace mm {
15 
35 template <class vec_t, class value_t>
37  private:
40  typedef typename vec_t::scalar_t scalar_t;
41 
42  public:
47  SheppardInterpolant() = default;
48 
53  explicit SheppardInterpolant(const Range<vec_t>& pos) : tree(pos) {
54  int N = pos.size();
55  assert_msg(N > 0, "Number of positions in the tree must be greater than 0, got %d.", N);
56  }
57 
64  : tree(pos), values(values) {
65  int N = pos.size();
66  int M = values.size();
67 
68  assert_msg(N > 0, "Number of positions in the tree must be greater than 0, got %d.", N);
69  assert_msg(N == M,
70  "Number of positions must equal number of values. Got %d positions in the tree "
71  "and %d values.",
72  N, M);
73  }
74 
79  template <typename values_container_t>
80  void setValues(const values_container_t& new_values) {
81  values = Range<value_t>(new_values.begin(), new_values.end());
82  }
83 
85  void setPositions(const Range<vec_t>& pos) { tree.reset(pos); }
86 
104  value_t operator()(const vec_t& point, int num_closest, int power = 2, double reg = 0.0,
105  double conf_dist = 1e-12) const;
106 };
107 
108 } // namespace mm
109 
110 #endif // MEDUSA_BITS_INTERPOLANTS_SHEPPARD_FWD_HPP_
mm::SheppardInterpolant::values
Range< value_t > values
Function values at given points.
Definition: Sheppard_fwd.hpp:39
mm
Root namespace for the whole library.
Definition: Gaussian.hpp:14
scalar_t
Scalar scalar_t
Type of the elements, alias of Scalar.
Definition: MatrixBaseAddons.hpp:16
mm::KDTree
Class representing a static k-d tree data structure.
Definition: KDTree_fwd.hpp:36
mm::SheppardInterpolant::operator()
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.
Definition: Sheppard.hpp:17
assert_msg
#define assert_msg(cond,...)
Assert with better error reporting.
Definition: assert.hpp:75
mm::SheppardInterpolant::tree
KDTree< vec_t > tree
Tree of all points.
Definition: Sheppard_fwd.hpp:38
mm::SheppardInterpolant::SheppardInterpolant
SheppardInterpolant(const Range< vec_t > &pos, const Range< value_t > &values)
Construct a new Sheppard Interpolant object.
Definition: Sheppard_fwd.hpp:63
mm::SheppardInterpolant
Scattered interpolant using a slightly modified Sheppard's interpolation (inverse distance weighting)...
Definition: Sheppard_fwd.hpp:36
Range_fwd.hpp
KDTree.hpp
mm::SheppardInterpolant::scalar_t
vec_t::scalar_t scalar_t
Scalar data type.
Definition: Sheppard_fwd.hpp:40
mm::Range::size
int size() const
Returns number of elements.
Definition: Range_fwd.hpp:185
mm::SheppardInterpolant::SheppardInterpolant
SheppardInterpolant()=default
Construct a new empty Sheppard Interpolant object.
mm::SheppardInterpolant::setPositions
void setPositions(const Range< vec_t > &pos)
Set new positions.
Definition: Sheppard_fwd.hpp:85
mm::SheppardInterpolant::setValues
void setValues(const values_container_t &new_values)
Set new values.
Definition: Sheppard_fwd.hpp:80
mm::Range< value_t >
mm::SheppardInterpolant::SheppardInterpolant
SheppardInterpolant(const Range< vec_t > &pos)
Construct a new Sheppard Interpolant.
Definition: Sheppard_fwd.hpp:53