mlpack  master
lmetric.hpp
Go to the documentation of this file.
1 
15 #ifndef MLPACK_CORE_METRICS_LMETRIC_HPP
16 #define MLPACK_CORE_METRICS_LMETRIC_HPP
17 
18 #include <mlpack/prereqs.hpp>
19 
20 namespace mlpack {
21 namespace metric {
22 
62 template<int TPower, bool TTakeRoot = true>
63 class LMetric
64 {
65  public:
66  /***
67  * Default constructor does nothing, but is required to satisfy the Metric
68  * policy.
69  */
70  LMetric() { }
71 
82  template<typename VecTypeA, typename VecTypeB>
83  static typename VecTypeA::elem_type Evaluate(const VecTypeA& a,
84  const VecTypeB& b);
85 
87  template<typename Archive>
88  void Serialize(Archive& /* ar */, const unsigned int /* version */) { }
89 
91  static const int Power = TPower;
93  static const bool TakeRoot = TTakeRoot;
94 };
95 
96 // Convenience typedefs.
97 
102 
108 
113 
118 
119 
120 } // namespace metric
121 } // namespace mlpack
122 
123 // Include implementation.
124 #include "lmetric_impl.hpp"
125 
126 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: binarize.hpp:18
LMetric< 2, true > EuclideanDistance
The Euclidean (L2) distance.
Definition: lmetric.hpp:112
The core includes that mlpack expects; standard C++ includes and Armadillo.
LMetric< 2, false > SquaredEuclideanDistance
The squared Euclidean (L2) distance.
Definition: lmetric.hpp:107
static VecTypeA::elem_type Evaluate(const VecTypeA &a, const VecTypeB &b)
Computes the distance between two points.
void Serialize(Archive &, const unsigned int)
Serialize the metric (nothing to do).
Definition: lmetric.hpp:88
LMetric< 1, false > ManhattanDistance
The Manhattan (L1) distance.
Definition: lmetric.hpp:101
The L_p metric for arbitrary integer p, with an option to take the root.
Definition: lmetric.hpp:63
static const int Power
The power of the metric.
Definition: lmetric.hpp:91
LMetric< INT_MAX, false > ChebyshevDistance
The L-infinity distance.
Definition: lmetric.hpp:117
static const bool TakeRoot
Whether or not the root is taken.
Definition: lmetric.hpp:93