facilities.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_CORE_CV_METRICS_FACILITIES_HPP
14 #define MLPACK_CORE_CV_METRICS_FACILITIES_HPP
15 
16 #include <mlpack/core.hpp>
18 
19 namespace mlpack {
20 namespace cv {
21 
28 template<typename DataType, typename Metric>
29 DataType PairwiseDistances(const DataType& data,
30  const Metric& metric)
31 {
32  DataType distances = DataType(data.n_cols, data.n_cols, arma::fill::none);
33  for (size_t i = 0; i < data.n_cols; i++)
34  {
35  for (size_t j = 0; j < i; j++)
36  {
37  distances(i, j) = metric.Evaluate(data.col(i), data.col(j));
38  distances(j, i) = distances(i, j);
39  }
40  }
41  distances.diag().zeros();
42  return distances;
43 }
44 
45 } // namespace cv
46 } // namespace mlpack
47 
48 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
Include all of the base components required to write mlpack methods, and the main mlpack Doxygen docu...
DataType PairwiseDistances(const DataType &data, const Metric &metric)
Pairwise distance of the given data.
Definition: facilities.hpp:29