27 : metric_description_(metric_description)
29 std::set<std::string> valid_types = {
"euclidean",
35 if (!valid_types.count(metric_description))
36 throw std::invalid_argument(
"Unsupported metric type " + metric_description);
49 if (metric_description_ ==
"squaredeuclidean")
50 return squared_euclidean_.Evaluate(first, second);
51 if (metric_description_ ==
"manhattan")
52 return manhattan_.Evaluate(first, second);
53 if (metric_description_ ==
"chebyshev")
54 return chebyshev_.Evaluate(first, second);
55 if (metric_description_ ==
"cosine")
56 return 1 - arma::norm_dot(first, second);
57 if (metric_description_ ==
"correlation")
58 return 1 - arma::as_scalar(arma::cor(first, second));
59 if (metric_description_ ==
"euclidean")
60 return euclidean_.Evaluate(first, second);
61 throw std::runtime_error(
"Unsupported metric type");
DistanceMetricWrapper(std::string metric_description)
Vespucci::Math::DistanceMetricWrapper::DistanceMetricWrapper.
double Evaluate(arma::vec &first, arma::vec &second)
Vespucci::Math::DistanceMetricWrapper::Evaluate.