38Distance_
compute_scale(
const std::pair<Distance_, Distance_>& ref,
const std::pair<Distance_, Distance_>& target) {
39 if (target.first == 0 || ref.first == 0) {
40 if (target.second == 0) {
41 return std::numeric_limits<Distance_>::infinity();
42 }
else if (ref.second == 0) {
45 return ref.second / target.second;
48 return ref.first / target.first;
66std::vector<Distance_>
compute_scale(
const std::vector<std::pair<Distance_, Distance_> >& distances) {
67 const auto ndist = distances.size();
68 auto output = sanisizer::create<std::vector<Distance_> >(ndist);
71 bool found_ref =
false;
72 I<
decltype(ndist)> ref = 0;
73 for (I<
decltype(ndist)> e = 0; e < ndist; ++e) {
74 if (distances[e].second) {
83 const auto& dref = distances[ref];
84 for (I<
decltype(ndist)> e = 0; e < ndist; ++e) {
85 output[e] = (e == ref ?
static_cast<Distance_
>(1) :
compute_scale(dref, distances[e]));
Distance_ compute_scale(const std::pair< Distance_, Distance_ > &ref, const std::pair< Distance_, Distance_ > &target)
Definition compute_scale.hpp:38