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
19namespace mlpack {
20namespace 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
86template<>
88{
89 public:
91 static const bool IsNormalized = true;
92};
93
94} // namespace kernel
95} // namespace mlpack
96
97#endif
double Evaluate(const VecTypeA &a, const VecTypeB &b)
Evaluation of the Cauchy kernel.
CauchyKernel(double bandwidth=1.0)
Construct the Cauchy kernel; by default, the bandwidth is 1.0.
void serialize(Archive &ar, const unsigned int)
Serialize the kernel.
This is a template class that can provide information about various kernels.
static const bool IsNormalized
If true, then the kernel is normalized: K(x, x) = K(y, y) = 1 for all x.
static VecTypeA::elem_type Evaluate(const VecTypeA &a, const VecTypeB &b)
Computes the distance between two points.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
The core includes that mlpack expects; standard C++ includes and Armadillo.