Medusa  1.1
Coordinate Free Mehless Method implementation
WeightFunction_fwd.hpp
Go to the documentation of this file.
1 #ifndef MEDUSA_BITS_APPROXIMATIONS_WEIGHTFUNCTION_FWD_HPP_
2 #define MEDUSA_BITS_APPROXIMATIONS_WEIGHTFUNCTION_FWD_HPP_
3 
11 #include <medusa/Config.hpp>
12 #include <array>
13 #include <iosfwd>
14 
15 namespace mm {
16 
24 template <class vec_t>
25 class NoWeight {
26  public:
27  typedef vec_t vector_t;
28  typedef typename vector_t::scalar_t scalar_t;
29  enum { dim = vec_t::dim };
31 
32  public:
34  scalar_t operator()(const vector_t& /* point */) const { return 1.0; }
35 
37  template <typename V>
38  friend std::ostream& operator<<(std::ostream& os, const NoWeight<V>& m);
39 };
40 
42 template <typename V>
43 std::ostream& operator<<(std::ostream& os, const NoWeight<V>& m) {
44  return os << "NoWeight " << m.dim << "D";
45 }
46 
62 template <class RBFType, class vec_t>
63 class RBFWeight {
64  static_assert(std::is_same<typename vec_t::scalar_t, typename RBFType::scalar_t>::value,
65  "Basis and underlying RBF must have the same scalar type.");
66  public:
67  typedef RBFType rbf_t;
68  typedef vec_t vector_t;
69  typedef typename vector_t::scalar_t scalar_t;
70  enum { dim = vec_t::dim };
72 
73  private:
75 
76  public:
78  RBFWeight() : rbf_() {}
80  RBFWeight(const rbf_t& rbf) : rbf_(rbf) {}
82  template <typename ...Args>
83  RBFWeight(Args&&... args) : rbf_(std::forward<Args>(args)...) {}
84 
86  const rbf_t& rbf() const { return rbf_; }
87 
89  rbf_t& rbf() { return rbf_; }
90 
92  scalar_t operator()(const vector_t& point) const { return rbf_(point.squaredNorm()); }
93 
95  template <typename V, typename R>
96  friend std::ostream& operator<<(std::ostream& os, const RBFWeight<V, R>& m);
97 };
98 
99 // Convenience typedefs
100 
101 template <typename S> class Gaussian;
104 
105 template <typename S> class Multiquadric;
107 template <typename V> using MQWeight = RBFWeight<Multiquadric<typename V::scalar_t>, V>;
108 
109 template <typename S> class InverseMultiquadric;
112 
113 template <typename S, int k> class Polyharmonic;
115 template <typename V> using PHWeight = RBFWeight<Polyharmonic<typename V::scalar_t, -1>, V>;
116 
117 } // namespace mm
118 
119 #endif // MEDUSA_BITS_APPROXIMATIONS_WEIGHTFUNCTION_FWD_HPP_
mm::NoWeight::vector_t
vec_t vector_t
Vector type.
Definition: WeightFunction_fwd.hpp:27
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::RBFWeight::RBFWeight
RBFWeight(const rbf_t &rbf)
Construct a weight from given RBF.
Definition: WeightFunction_fwd.hpp:80
mm::RBFWeight::rbf
const rbf_t & rbf() const
Returns underlying RBF object.
Definition: WeightFunction_fwd.hpp:86
mm::InverseMultiquadric
Inverse Multiquadric Radial Basis Function.
Definition: InverseMultiquadric_fwd.hpp:29
dim
@ dim
Number of elements of this matrix.
Definition: MatrixBaseAddons.hpp:14
mm::RBFWeight::rbf_
rbf_t rbf_
RBF function.
Definition: WeightFunction_fwd.hpp:74
mm::operator<<
std::ostream & operator<<(std::ostream &os, const Gaussian< S > &b)
Output basic information about given Gaussian RBF.
Definition: Gaussian.hpp:37
mm::NoWeight
Class representing no weight function, i.e. a constant 1.
Definition: WeightFunction_fwd.hpp:25
mm::NoWeight::operator<<
friend std::ostream & operator<<(std::ostream &os, const NoWeight< V > &m)
Output basic info about given weight function.
Definition: WeightFunction_fwd.hpp:43
mm::NoWeight::scalar_t
vector_t::scalar_t scalar_t
Scalar type.
Definition: WeightFunction_fwd.hpp:28
Config.hpp
mm::RBFWeight::operator()
scalar_t operator()(const vector_t &point) const
Evaluate weight function at point.
Definition: WeightFunction_fwd.hpp:92
mm::NoWeight::operator()
scalar_t operator()(const vector_t &) const
Evaluate weight function at point. Returns 1.
Definition: WeightFunction_fwd.hpp:34
mm::RBFWeight::RBFWeight
RBFWeight(Args &&... args)
Perfect forwarding constructor. Construct RBFWeight as if you were constructing given RBF.
Definition: WeightFunction_fwd.hpp:83
mm::RBFWeight::rbf_t
RBFType rbf_t
Radial basis function type.
Definition: WeightFunction_fwd.hpp:65
mm::NoWeight::dim
@ dim
Dimensionality of the function domain.
Definition: WeightFunction_fwd.hpp:30
mm::Multiquadric
Multiquadric Radial Basis Function.
Definition: Multiquadric_fwd.hpp:29
mm::Polyharmonic
Polyharmonic Radial Basis Function of odd order.
Definition: Polyharmonic_fwd.hpp:32
mm::RBFWeight
Represents a weight function constructed from a Radial Basis function.
Definition: WeightFunction_fwd.hpp:63
mm::RBFWeight::RBFWeight
RBFWeight()
Construct a weight with default construction of RBF.
Definition: WeightFunction_fwd.hpp:78
mm::RBFWeight::dim
@ dim
Dimensionality of the function domain.
Definition: WeightFunction_fwd.hpp:71
mm::RBFWeight::operator<<
friend std::ostream & operator<<(std::ostream &os, const RBFWeight< V, R > &m)
Output basic info about given weight function.
Definition: WeightFunction.hpp:17
mm::RBFWeight::rbf
rbf_t & rbf()
Returns modifiable underlying RBF object.
Definition: WeightFunction_fwd.hpp:89
mm::RBFWeight::scalar_t
vector_t::scalar_t scalar_t
Scalar type.
Definition: WeightFunction_fwd.hpp:69
mm::RBFWeight::vector_t
vec_t vector_t
Vector type.
Definition: WeightFunction_fwd.hpp:68