12 #ifndef __MLPACK_CORE_KERNELS_SPHERICAL_KERNEL_HPP 13 #define __MLPACK_CORE_KERNELS_SPHERICAL_KERNEL_HPP 15 #include <boost/math/special_functions/gamma.hpp> 45 template<
typename VecTypeA,
typename VecTypeB>
46 double Evaluate(
const VecTypeA& a,
const VecTypeB& b)
const 63 template<
typename VecTypeA,
typename VecTypeB>
71 double volumeSquared = pow(
Normalizer(a.n_rows), 2.0);
76 return 1.0 / volumeSquared * (2.0 *
bandwidth - distance);
79 return 1.0 / volumeSquared *
84 Log::Fatal <<
"The spherical kernel does not support convolution\ 85 integrals above dimension two, yet..." << std::endl;
92 return pow(
bandwidth, (
double) dimension) * pow(
M_PI, dimension / 2.0) /
93 boost::math::tgamma(dimension / 2.0 + 1.0);
106 return t ==
bandwidth ? arma::datum::nan : 0.0;
110 template<
typename Archive>
128 static const bool IsNormalized =
true;
130 static const bool UsesSquaredDistance =
false;
double Gradient(double t)
void Serialize(Archive &ar, const unsigned int)
Serialize the object.
This is a template class that can provide information about various kernels.
double Evaluate(const VecTypeA &a, const VecTypeB &b) const
Evaluate the spherical kernel with the given two vectors.
Linear algebra utility functions, generally performed on matrices or vectors.
FirstShim< T > CreateNVP(T &t, const std::string &name, typename boost::enable_if< HasSerialize< T >>::type *=0)
Call this function to produce a name-value pair; this is similar to BOOST_SERIALIZATION_NVP(), but should be used for types that have a Serialize() function (or contain a type that has a Serialize() function) instead of a serialize() function.
SphericalKernel(const double bandwidth=1.0)
Construct the SphericalKernel with the given bandwidth.
double ConvolutionIntegral(const VecTypeA &a, const VecTypeB &b) const
Obtains the convolution integral [integral K(||x-a||)K(||b-x||)dx] for the two vectors.
static util::PrefixedOutStream Fatal
Prints fatal messages prefixed with [FATAL], then terminates the program.
double Evaluate(const double t) const
Evaluate the kernel when only a distance is given, not two points.
double Normalizer(size_t dimension) const
Include all of the base components required to write MLPACK methods, and the main MLPACK Doxygen docu...
The spherical kernel, which is 1 when the distance between the two argument points is less than or eq...
static double Evaluate(const VecTypeA &a, const VecTypeB &b)
Computes the distance between two points.