23 #ifndef __MLPACK_CORE_KERNELS_SPHERICAL_KERNEL_H
24 #define __MLPACK_CORE_KERNELS_SPHERICAL_KERNEL_H
26 #include <boost/math/special_functions/gamma.hpp>
42 template<
typename VecType>
43 double Evaluate(
const VecType& a,
const VecType& b)
61 template<
typename VecType>
69 double volumeSquared = pow(
Normalizer(a.n_rows), 2.0);
74 return 1.0 / volumeSquared * (2.0 *
bandwidth - distance);
77 return 1.0 / volumeSquared *
82 Log::Fatal <<
"The spherical kernel does not support convolution\
83 integrals above dimension two, yet..." << std::endl;
90 return pow(
bandwidth, (
double) dimension) * pow(
M_PI, dimension / 2.0) /
91 boost::math::tgamma(dimension / 2.0 + 1.0);
101 std::ostringstream convert;
102 convert <<
"SphericalKernel [" <<
this <<
"]" << std::endl;
103 convert <<
" Bandwidth: " <<
bandwidth << std::endl;
104 return convert.str();