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 uint32_t /* version */)
76  {
77  ar(CEREAL_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
This is a template class that can provide information about various kernels.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
static VecTypeA::elem_type Evaluate(const VecTypeA &a, const VecTypeB &b)
Computes the distance between two points.
CauchyKernel(double bandwidth=1.0)
Construct the Cauchy kernel; by default, the bandwidth is 1.0.
void serialize(Archive &ar, const uint32_t)
Serialize the kernel.
double Evaluate(const VecTypeA &a, const VecTypeB &b)
Evaluation of the Cauchy kernel.