Medusa  1.1
Coordinate Free Mehless Method implementation
Gaussian.hpp
Go to the documentation of this file.
1 #ifndef MEDUSA_BITS_APPROXIMATIONS_GAUSSIAN_HPP_
2 #define MEDUSA_BITS_APPROXIMATIONS_GAUSSIAN_HPP_
3 
9 #include "Gaussian_fwd.hpp"
10 #include <cmath>
13 
14 namespace mm {
15 
16 template <typename scal_t>
17 Gaussian<scal_t>::Gaussian(scal_t shape) : shape_(shape) {
18  assert_msg(shape_ > 0, "Shape should be greater than 0, got %s.", shape_);
19 }
20 
21 template <class scal_t>
22 scal_t Gaussian<scal_t>::operator()(scal_t r2, int derivative) const {
23  assert_msg(derivative >= 0, "Derivative of negative order %d requested.", derivative);
24  scal_t f = -1.0/shape_/shape_;
25  return std::exp(r2*f) * ipow(f, derivative);
26 }
28 template <class scal_t>
29 template <int dimension>
31  scal_t f = -1.0/shape_/shape_;
32  return (2*dimension*f + 4*r2*(f*f)) * std::exp(r2*f);
33 }
36 template <class S>
37 std::ostream& operator<<(std::ostream& os, const Gaussian<S>& b) {
38  return os << "Gaussian RBF with shape " << b.shape();
39 }
40 
41 } // namespace mm
42 
43 #endif // MEDUSA_BITS_APPROXIMATIONS_GAUSSIAN_HPP_
mm
Root namespace for the whole library.
Definition: Gaussian.hpp:14
mm::Gaussian::shape_
scalar_t shape_
Shape parameter.
Definition: Gaussian_fwd.hpp:34
scalar_t
Scalar scalar_t
Type of the elements, alias of Scalar.
Definition: MatrixBaseAddons.hpp:16
Gaussian_fwd.hpp
mm::Gaussian::shape
scalar_t shape() const
Returns shape parameter.
Definition: Gaussian_fwd.hpp:41
mm::ipow
double ipow(double base)
Compile time integer power, returns base raised to power exponent.
Definition: numutils.hpp:40
mm::operator<<
std::ostream & operator<<(std::ostream &os, const Gaussian< S > &b)
Output basic information about given Gaussian RBF.
Definition: Gaussian.hpp:37
numutils.hpp
assert_msg
#define assert_msg(cond,...)
Assert with better error reporting.
Definition: assert.hpp:75
mm::Gaussian::Gaussian
Gaussian(scalar_t shape=1.0)
Creates a Gaussian RBF with shape parameter shape. The shape should be positive.
Definition: Gaussian.hpp:17
mm::Gaussian::operator()
scalar_t operator()(scalar_t r2, int derivative) const
Evaluate derivative of this RBF wrt.
Definition: Gaussian.hpp:22
assert.hpp
mm::Gaussian
Gaussian Radial Basis Function.
Definition: Gaussian_fwd.hpp:29
mm::Lap
Represents the Laplacian operator.
Definition: Monomials_fwd.hpp:20