#ifndef MEDUSA_BITS_APPROXIMATIONS_GAUSSIAN_HPP_ #define MEDUSA_BITS_APPROXIMATIONS_GAUSSIAN_HPP_ /** * @file * Implementation of Gaussian RBF. */ #include "Gaussian_fwd.hpp" #include #include #include namespace mm { template Gaussian::Gaussian(scal_t shape) : shape_(shape) { assert_msg(shape_ > 0, "Shape should be greater than 0, got %s.", shape_); } template scal_t Gaussian::operator()(scal_t r2, int derivative) const { assert_msg(derivative >= 0, "Derivative of negative order %d requested.", derivative); scal_t f = -1.0/shape_/shape_; return std::exp(r2*f) * ipow(f, derivative); } /// @cond template template scal_t Gaussian::operator()(scalar_t r2, Lap) const { scal_t f = -1.0/shape_/shape_; return (2*dimension*f + 4*r2*(f*f)) * std::exp(r2*f); } /// @endcond /// Output basic information about given Gaussian RBF. template std::ostream& operator<<(std::ostream& os, const Gaussian& b) { return os << "Gaussian RBF with shape " << b.shape(); } } // namespace mm #endif // MEDUSA_BITS_APPROXIMATIONS_GAUSSIAN_HPP_