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();
This is a template class that can provide information about various kernels.
Linear algebra utility functions, generally performed on matrices or vectors.
SphericalKernel(double b)
static util::PrefixedOutStream Fatal
Prints fatal messages prefixed with [FATAL], then terminates the program.
static double Evaluate(const VecType1 &a, const VecType2 &b)
Computes the distance between two points.
double ConvolutionIntegral(const VecType &a, const VecType &b)
Obtains the convolution integral [integral K(||x-a||)K(||b-x||)dx] for the two vectors.
std::string ToString() const
Return a string representation of the kernel.
double Normalizer(size_t dimension)
static const bool IsNormalized
If true, then the kernel is normalized: K(x, x) = K(y, y) = 1 for all x.
double Evaluate(const VecType &a, const VecType &b)
double Evaluate(double t)