#ifndef MEDUSA_BITS_APPROXIMATIONS_WEIGHTFUNCTION_FWD_HPP_ #define MEDUSA_BITS_APPROXIMATIONS_WEIGHTFUNCTION_FWD_HPP_ /** * @file * Declarations of weight functions. * * @example test/approximations/WeightFunction_test.cpp */ #include #include #include namespace mm { /** * Class representing no weight function, i.e.\ a constant 1. * Used in WLS computations of shape functions. This class satisfies the @ref weight-concept. * Usage example: see WLS. * @sa RBFWeight, GaussianWeight, MQWeight, IMQWeight, PHWeight * @ingroup approximations */ template class NoWeight { public: typedef vec_t vector_t; ///< Vector type. typedef typename vector_t::scalar_t scalar_t; ///< Scalar type. /// Store dimension of the domain. enum { /** Dimensionality of the function domain. */ dim = vec_t::dim }; public: /// Evaluate weight function at `point`. Returns `1`. scalar_t operator()(const vector_t& /* point */) const { return 1.0; } /// Output basic info about given weight function. template friend std::ostream& operator<<(std::ostream& os, const NoWeight& m); }; /// Output basic info about given weight function. template std::ostream& operator<<(std::ostream& os, const NoWeight& m) { return os << "NoWeight " << m.dim << "D"; } /** * Represents a weight function constructed from a Radial Basis function. * @tparam RBFType Type of the RBF used. Must satisfy the @ref rbf-concept. * @tparam vec_t Vector type used in calculations. * * The weight function @f$w@f$ is defined as @f$w(x) = f(\|x\|_2^2)@f$, where @f$f@f$ is the * given radial basis function. * * This class satisfies the @ref weight-concept. * * Usage example: * @snippet approximations/WeightFunction_test.cpp RBF weight usage example * @sa NoWeight, GaussianWeight, MQWeight, IMQWeight, PHWeight * @ingroup approximations */ template class RBFWeight { static_assert(std::is_same::value, "Basis and underlying RBF must have the same scalar type."); public: typedef RBFType rbf_t; ///< Radial basis function type. typedef vec_t vector_t; ///< Vector type. typedef typename vector_t::scalar_t scalar_t; ///< Scalar type. /// Store dimension of the domain. enum { /** Dimensionality of the function domain. */ dim = vec_t::dim }; private: rbf_t rbf_; ///< RBF function. public: /// Construct a weight with default construction of RBF. RBFWeight() : rbf_() {} /// Construct a weight from given RBF. RBFWeight(const rbf_t& rbf) : rbf_(rbf) {} /// Perfect forwarding constructor. Construct RBFWeight as if you were constructing given RBF. template RBFWeight(Args&&... args) : rbf_(std::forward(args)...) {} /// Returns underlying RBF object. const rbf_t& rbf() const { return rbf_; } /// Returns modifiable underlying RBF object. rbf_t& rbf() { return rbf_; } /// Evaluate weight function at `point`. scalar_t operator()(const vector_t& point) const { return rbf_(point.squaredNorm()); } /// Output basic info about given weight function. template friend std::ostream& operator<<(std::ostream& os, const RBFWeight& m); }; // Convenience typedefs template class Gaussian; /// RBF weight function using Gaussian RBF. Defined for convenience. template using GaussianWeight = RBFWeight, V>; template class Multiquadric; /// RBF weight function using Multiquadric RBF. Defined for convenience. template using MQWeight = RBFWeight, V>; template class InverseMultiquadric; /// RBF weight function using InverseMultiquadric RBF. Defined for convenience. template using IMQWeight = RBFWeight, V>; template class Polyharmonic; /// RBF weight function using Polyharmonic RBF. Defined for convenience. template using PHWeight = RBFWeight, V>; } // namespace mm #endif // MEDUSA_BITS_APPROXIMATIONS_WEIGHTFUNCTION_FWD_HPP_