mlpack  3.4.2
cauchy_kernel.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_CORE_KERNELS_CAUCHY_KERNEL_HPP
13 #define MLPACK_CORE_KERNELS_CAUCHY_KERNEL_HPP
14 
15 #include <mlpack/prereqs.hpp>
18 
19 namespace mlpack {
20 namespace kernel {
21 
45 {
46  public:
50  CauchyKernel(double bandwidth = 1.0) : bandwidth(bandwidth)
51  { }
52 
64  template<typename VecTypeA, typename VecTypeB>
65  double Evaluate(const VecTypeA& a, const VecTypeB& b)
66  {
67  return 1 / (1 + (
68  std::pow(metric::EuclideanDistance::Evaluate(a, b) / bandwidth, 2)));
69  }
70 
74  template<typename Archive>
75  void serialize(Archive& ar, const unsigned int /* version */)
76  {
77  ar & BOOST_SERIALIZATION_NVP(bandwidth);
78  }
79 
80  private:
82  double bandwidth;
83 };
84 
86 template<>
88 {
89  public:
91  static const bool IsNormalized = true;
92 };
93 
94 } // namespace kernel
95 } // namespace mlpack
96 
97 #endif
mlpack::kernel::KernelTraits
This is a template class that can provide information about various kernels.
Definition: kernel_traits.hpp:28
mlpack::kernel::KernelTraits::IsNormalized
static const bool IsNormalized
If true, then the kernel is normalized: K(x, x) = K(y, y) = 1 for all x.
Definition: kernel_traits.hpp:33
mlpack::kernel::CauchyKernel::Evaluate
double Evaluate(const VecTypeA &a, const VecTypeB &b)
Evaluation of the Cauchy kernel.
Definition: cauchy_kernel.hpp:65
prereqs.hpp
The core includes that mlpack expects; standard C++ includes and Armadillo.
mlpack::kernel::CauchyKernel::serialize
void serialize(Archive &ar, const unsigned int)
Serialize the kernel.
Definition: cauchy_kernel.hpp:75
mlpack::metric::LMetric< 2, true >::Evaluate
static VecTypeA::elem_type Evaluate(const VecTypeA &a, const VecTypeB &b)
Computes the distance between two points.
lmetric.hpp
mlpack
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: add_to_cli11.hpp:21
mlpack::kernel::CauchyKernel
The Cauchy kernel.
Definition: cauchy_kernel.hpp:45
kernel_traits.hpp
mlpack::kernel::CauchyKernel::CauchyKernel
CauchyKernel(double bandwidth=1.0)
Construct the Cauchy kernel; by default, the bandwidth is 1.0.
Definition: cauchy_kernel.hpp:50