#ifndef MEDUSA_BITS_APPROXIMATIONS_RBFINTERPOLANT_HPP_ #define MEDUSA_BITS_APPROXIMATIONS_RBFINTERPOLANT_HPP_ /** * @file * Implementation of the RBFInterpolant class. */ #include "RBFInterpolant_fwd.hpp" #include "RBFBasis.hpp" #include namespace mm { template RBFInterpolant::RBFInterpolant( const rbf_t& rbf, const Monomials& mon, const vector_t& point, const std::vector& support, scalar_t scale, const Eigen::Matrix& coefficients) : rbf_(rbf), mon_(mon), point_(point), support_(support), scale_(scale), coefficients_(coefficients) { int n = support_.size(); for (int i = 0; i < n; ++i) { support_[i] -= point; support_[i] /= scale; } } template typename vec_t::scalar_t RBFInterpolant::operator()(const vector_t& point) const { int n1 = support_.size(); int n2 = mon_.size(); vector_t local_point = (point - point_) / scale_; Eigen::Matrix b(n1 + n2); for (int i = 0; i < n1; ++i) { b(i) = rbf_((local_point - support_[i]).squaredNorm()); } for (int i = 0; i < n2; ++i) { b(n1+i) = mon_.eval(i, local_point); } return b.dot(coefficients_); } /// @cond template template typename vec_t::scalar_t RBFInterpolant::operator()(const vector_t& point, const operator_t& op) const { int n1 = support_.size(); int n2 = mon_.size(); vector_t local_point = (point - point_) / scale_; RBFBasis rbf_basis(n1, rbf_); Eigen::Matrix b(n1 + n2); for (int i = 0; i < n1; ++i) { b(i) = rbf_basis.evalOp(i, local_point, op, support_); } for (int i = 0; i < n2; ++i) { b(n1+i) = mon_.evalOp(i, local_point, op); } return b.dot(coefficients_); } /// @endcond } // namespace mm #endif // MEDUSA_BITS_APPROXIMATIONS_RBFINTERPOLANT_HPP_