mlpack  3.4.2
cosine_distance.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_CORE_KERNELS_COSINE_DISTANCE_HPP
14 #define MLPACK_CORE_KERNELS_COSINE_DISTANCE_HPP
15 
16 #include <mlpack/prereqs.hpp>
18 
19 namespace mlpack {
20 namespace kernel {
21 
32 {
33  public:
41  template<typename VecTypeA, typename VecTypeB>
42  static double Evaluate(const VecTypeA& a, const VecTypeB& b);
43 
45  template<typename Archive>
46  void serialize(Archive& /* ar */, const unsigned int /* version */) { }
47 };
48 
50 template<>
52 {
53  public:
55  static const bool IsNormalized = true;
56 
58  static const bool UsesSquaredDistance = false;
59 };
60 
61 } // namespace kernel
62 } // namespace mlpack
63 
64 // Include implementation.
65 #include "cosine_distance_impl.hpp"
66 
67 #endif
mlpack::kernel::KernelTraits
This is a template class that can provide information about various kernels.
Definition: kernel_traits.hpp:28
mlpack::kernel::CosineDistance::Evaluate
static double Evaluate(const VecTypeA &a, const VecTypeB &b)
Computes the cosine distance between two points.
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
prereqs.hpp
The core includes that mlpack expects; standard C++ includes and Armadillo.
mlpack::kernel::CosineDistance
The cosine distance (or cosine similarity).
Definition: cosine_distance.hpp:32
mlpack
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: add_to_cli11.hpp:21
mlpack::kernel::CosineDistance::serialize
void serialize(Archive &, const unsigned int)
Serialize the class (there's nothing to save).
Definition: cosine_distance.hpp:46
kernel_traits.hpp
mlpack::kernel::KernelTraits::UsesSquaredDistance
static const bool UsesSquaredDistance
If true, then the kernel include a squared distance, ||x - y||^2 .
Definition: kernel_traits.hpp:38