Medusa  1.1
Coordinate Free Mehless Method implementation
RBFBasis_fwd.hpp
Go to the documentation of this file.
1 #ifndef MEDUSA_BITS_APPROXIMATIONS_RBFBASIS_FWD_HPP_
2 #define MEDUSA_BITS_APPROXIMATIONS_RBFBASIS_FWD_HPP_
3 
11 #include <medusa/Config.hpp>
12 #include <iosfwd>
13 #include <array>
14 #include "Operators_fwd.hpp"
15 
16 namespace mm {
17 
29 template <class RBFType, class vec_t>
30 class RBFBasis {
31  static_assert(std::is_same<typename vec_t::scalar_t, typename RBFType::scalar_t>::value,
32  "Basis and underlying RBF must have the same scalar type.");
33  public:
34  typedef RBFType rbf_t;
35  typedef vec_t vector_t;
36  typedef typename vector_t::scalar_t scalar_t;
37  enum { dim = vec_t::dim };
39 
40  private:
41  int size_;
43 
44  public:
46  explicit RBFBasis(int basis_size) : size_(basis_size), rbf_() {}
48  RBFBasis(int basis_size, const rbf_t& rbf) : size_(basis_size), rbf_(rbf) {}
49 
51  int size() const { return size_; }
52 
54  const rbf_t& rbf() const { return rbf_; }
55 
57  rbf_t& rbf() { return rbf_; }
58 
59 
72  scalar_t eval(int index, const vector_t& point, const std::vector<vector_t>& support) const;
73 
86  template <typename operator_t>
87  scalar_t evalOp(int index, const vector_t& point, operator_t op,
88  const std::vector<vector_t>& support, scalar_t scale = 1) const;
90  scalar_t evalOp(int index, const vector_t& point, Lap<dim> op,
91  const std::vector<vector_t>& support, scalar_t scale = 1) const;
93  scalar_t evalOp(int index, const vector_t& point, Der1<dim> op,
94  const std::vector<vector_t>& support, scalar_t scale = 1) const;
96  scalar_t evalOp(int index, const vector_t& point, Der2<dim> op,
97  const std::vector<vector_t>& support, scalar_t scale = 1) const;
98 
100  scalar_t evalAt0(int index, const std::vector<vector_t>& support) const;
101 
114  template <typename operator_t>
115  scalar_t evalOpAt0(int index, const operator_t& op, const std::vector<vector_t>& support,
116  scalar_t scale = 1) const {
117  return op.applyAt0(*this, index, support, scale);
118  }
120  scalar_t evalOpAt0(int index, const Lap<dim>& lap, const std::vector<vector_t>& support,
121  scalar_t scale = 1) const;
123  scalar_t evalOpAt0(int index, const Der1<dim>& der1, const std::vector<vector_t>& support,
124  scalar_t scale = 1) const;
126  scalar_t evalOpAt0(int index, const Der2<dim>& der2, const std::vector<vector_t>& support,
127  scalar_t scale = 1) const;
128 
130  template <typename V, typename R>
131  friend std::ostream& operator<<(std::ostream& os, const RBFBasis<V, R>& m);
132 };
133 
134 
135 // Convenience typedefs
136 
137 template <typename S> class Gaussian;
139 template <typename V> using Gaussians = RBFBasis<Gaussian<typename V::scalar_t>, V>;
140 
141 template <typename S> class Multiquadric;
143 template <typename V> using MQs = RBFBasis<Multiquadric<typename V::scalar_t>, V>;
144 
145 template <typename S> class InverseMultiquadric;
148 
149 template <typename S, int K> class Polyharmonic;
151 template <typename V, int K = -1> using PHs = RBFBasis<Polyharmonic<typename V::scalar_t, K>, V>;
152 
153 } // namespace mm
154 
155 #endif // MEDUSA_BITS_APPROXIMATIONS_RBFBASIS_FWD_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::RBFBasis::vector_t
vec_t vector_t
Vector type.
Definition: RBFBasis_fwd.hpp:35
mm::sh::lap
static const shape_flags lap
Indicates to calculate laplace shapes.
Definition: shape_flags.hpp:24
mm::InverseMultiquadric
Inverse Multiquadric Radial Basis Function.
Definition: InverseMultiquadric_fwd.hpp:29
mm::RBFBasis::rbf_t
RBFType rbf_t
Radial basis function type.
Definition: RBFBasis_fwd.hpp:32
dim
@ dim
Number of elements of this matrix.
Definition: MatrixBaseAddons.hpp:14
mm::RBFBasis::dim
@ dim
Dimensionality of the function domain.
Definition: RBFBasis_fwd.hpp:38
mm::RBFBasis::eval
scalar_t eval(int index, const vector_t &point, const std::vector< vector_t > &support) const
Evaluates index-th RBF's at point.
mm::RBFBasis::evalAt0
scalar_t evalAt0(int index, const std::vector< vector_t > &support) const
Evaluate index-th function at zero.
Definition: RBFBasis.hpp:74
Config.hpp
mm::RBFBasis::scalar_t
vector_t::scalar_t scalar_t
Scalar type.
Definition: RBFBasis_fwd.hpp:36
mm::RBFBasis::evalOp
scalar_t evalOp(int index, const vector_t &point, operator_t op, const std::vector< vector_t > &support, scalar_t scale=1) const
Apply an operator at a given point.
mm::Der2
Represents a second derivative wrt. var1 and var2.
Definition: Monomials_fwd.hpp:24
Operators_fwd.hpp
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::RBFBasis::rbf
rbf_t & rbf()
Returns modifiable underlying RBF object.
Definition: RBFBasis_fwd.hpp:57
mm::RBFBasis
Represents a basis of Radial Basis Functions over a local neighbourhood.
Definition: RBFBasis_fwd.hpp:30
mm::Lap
Represents the Laplacian operator.
Definition: Monomials_fwd.hpp:20
mm::RBFBasis::RBFBasis
RBFBasis(int basis_size, const rbf_t &rbf)
Construct a basis of basis_size with given RBF.
Definition: RBFBasis_fwd.hpp:48
mm::Der1
Represents a first derivative wrt. var.
Definition: Monomials_fwd.hpp:22
mm::RBFBasis::rbf_
rbf_t rbf_
RBF function.
Definition: RBFBasis_fwd.hpp:42
mm::RBFBasis::size
int size() const
Returns basis size.
Definition: RBFBasis_fwd.hpp:51
mm::RBFBasis::RBFBasis
RBFBasis(int basis_size)
Construct a basis of basis_size with default construction of RBF.
Definition: RBFBasis_fwd.hpp:46
mm::RBFBasis::size_
int size_
Basis size.
Definition: RBFBasis_fwd.hpp:41
mm::RBFBasis::rbf
const rbf_t & rbf() const
Returns underlying RBF object.
Definition: RBFBasis_fwd.hpp:54
mm::RBFBasis::evalOpAt0
scalar_t evalOpAt0(int index, const operator_t&op, const std::vector< vector_t > &support, scalar_t scale=1) const
Evaluate general operator op at zero.
Definition: RBFBasis_fwd.hpp:115
mm::RBFBasis::operator<<
friend std::ostream & operator<<(std::ostream &os, const RBFBasis< V, R > &m)
Output basic info about given basis.
Definition: RBFBasis.hpp:139