10 #ifndef MLPACK_CORE_KERNELS_SPHERICAL_KERNEL_HPP 11 #define MLPACK_CORE_KERNELS_SPHERICAL_KERNEL_HPP 13 #include <boost/math/special_functions/gamma.hpp> 43 template<
typename VecTypeA,
typename VecTypeB>
44 double Evaluate(
const VecTypeA& a,
const VecTypeB& b)
const 61 template<
typename VecTypeA,
typename VecTypeB>
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 std::tgamma(dimension / 2.0 + 1.0);
104 return t ==
bandwidth ? arma::datum::nan : 0.0;
108 template<
typename Archive>
126 static const bool IsNormalized =
true;
128 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.
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.
The core includes that mlpack expects; standard C++ includes and Armadillo.
FirstShim< T > CreateNVP(T &t, const std::string &name, typename std::enable_if_t< HasSerialize< T >::value > *=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.
double Evaluate(const double t) const
Evaluate the kernel when only a distance is given, not two points.
static VecTypeA::elem_type Evaluate(const VecTypeA &a, const VecTypeB &b)
Computes the distance between two points.
double Normalizer(size_t dimension) const
static MLPACK_EXPORT util::PrefixedOutStream Fatal
Prints fatal messages prefixed with [FATAL], then terminates the program.
The spherical kernel, which is 1 when the distance between the two argument points is less than or eq...