Medusa  1.1
Coordinate Free Mehless Method implementation
RBFInterpolant.hpp
Go to the documentation of this file.
1 #ifndef MEDUSA_BITS_APPROXIMATIONS_RBFINTERPOLANT_HPP_
2 #define MEDUSA_BITS_APPROXIMATIONS_RBFINTERPOLANT_HPP_
3 
9 #include "RBFInterpolant_fwd.hpp"
10 #include "RBFBasis.hpp"
12 
13 namespace mm {
14 
15 template <typename RBFType, typename vec_t>
17  const rbf_t& rbf, const Monomials<vec_t>& mon, const vector_t& point,
18  const std::vector<vector_t>& support, scalar_t scale,
19  const Eigen::Matrix<scalar_t, Eigen::Dynamic, 1>& coefficients) :
20  rbf_(rbf), mon_(mon), point_(point), support_(support), scale_(scale),
21  coefficients_(coefficients) {
22  int n = support_.size();
23  for (int i = 0; i < n; ++i) {
24  support_[i] -= point;
25  support_[i] /= scale;
26  }
27 }
28 
29 template <typename RBFType, typename vec_t>
31  int n1 = support_.size();
32  int n2 = mon_.size();
33  vector_t local_point = (point - point_) / scale_;
34  Eigen::Matrix<scalar_t, Eigen::Dynamic, 1> b(n1 + n2);
35  for (int i = 0; i < n1; ++i) {
36  b(i) = rbf_((local_point - support_[i]).squaredNorm());
37  }
38  for (int i = 0; i < n2; ++i) {
39  b(n1+i) = mon_.eval(i, local_point);
40  }
41  return b.dot(coefficients_);
42 }
43 
45 template <typename RBFType, typename vec_t>
46 template <typename operator_t>
47 typename vec_t::scalar_t
48 RBFInterpolant<RBFType, vec_t>::operator()(const vector_t& point, const operator_t& op) const {
49  int n1 = support_.size();
50  int n2 = mon_.size();
51  vector_t local_point = (point - point_) / scale_;
52  RBFBasis<rbf_t, vec_t> rbf_basis(n1, rbf_);
53  Eigen::Matrix<scalar_t, Eigen::Dynamic, 1> b(n1 + n2);
54  for (int i = 0; i < n1; ++i) {
55  b(i) = rbf_basis.evalOp(i, local_point, op, support_);
56  }
57  for (int i = 0; i < n2; ++i) {
58  b(n1+i) = mon_.evalOp(i, local_point, op);
59  }
60  return b.dot(coefficients_);
61 }
63 
64 } // namespace mm
65 
66 #endif // MEDUSA_BITS_APPROXIMATIONS_RBFINTERPOLANT_HPP_
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::RBFInterpolant::scale
scalar_t scale() const
Get the scale.
Definition: RBFInterpolant_fwd.hpp:78
mm::RBFInterpolant::point
const vector_t & point() const
Get the center point.
Definition: RBFInterpolant_fwd.hpp:76
mm::Monomials
A class representing Monomial basis.
Definition: Monomials_fwd.hpp:38
RBFInterpolant_fwd.hpp
assert.hpp
mm::RBFBasis
Represents a basis of Radial Basis Functions over a local neighbourhood.
Definition: RBFBasis_fwd.hpp:30
RBFBasis.hpp
mm::RBFInterpolant::rbf_t
RBFType rbf_t
Radial basis function type.
Definition: RBFInterpolant_fwd.hpp:38
mm::RBFInterpolant::scalar_t
vec_t::scalar_t scalar_t
Scalar type.
Definition: RBFInterpolant_fwd.hpp:36
mm::RBFInterpolant::vector_t
vec_t vector_t
Vector type.
Definition: RBFInterpolant_fwd.hpp:37
mm::RBFInterpolant::RBFInterpolant
RBFInterpolant(const rbf_t &rbf, const Monomials< vec_t > &mon, const vector_t &point, const std::vector< vector_t > &support, scalar_t scale, const Eigen::Matrix< scalar_t, Eigen::Dynamic, 1 > &coefficients)
Construct a RBF interpolant with known coefficients.
Definition: RBFInterpolant.hpp:16
mm::RBFInterpolant::operator()
scalar_t operator()(const vector_t &point) const
Evaluate the interpolant at given point.
Definition: RBFInterpolant.hpp:30
mm::RBFInterpolant::support_
std::vector< vector_t > support_
Local scaled stencil points.
Definition: RBFInterpolant_fwd.hpp:44