32 template<
typename InputIterator,
typename T = value_type_i<InputIterator>>
33 T
norm(InputIterator first, InputIterator last, T init = T{})
35 const auto add_abs = [](
const auto left,
const auto right) -> T
37 return left + std::abs(right);
39 return std::accumulate(first, last, init, add_abs);
45 template<
typename Container,
typename T = value_type<Container>>
46 T
norm(
const Container& a, T init = T{})
50 return norm(begin(a), end(a), init);
56 template<
typename InputIterator,
typename T = value_type_i<InputIterator>>
57 T
squared_norm(InputIterator first, InputIterator last, T init = T{})
59 const auto n =
norm(first, last, init);
66 template<
typename Container,
typename T = value_type<Container>>
78 template<
typename InputIterator1,
typename InputIterator2,
typename T = value_type_i<InputIterator1>>
79 T
distance(InputIterator1 first_left, InputIterator1 last_left, InputIterator2 first_right, T init = T{})
81 auto op1 = [](
const T left,
const T right) -> T
85 auto op2 = [](
const auto left,
const auto right) -> T
87 return std::abs(left - right);
89 return std::inner_product(first_left, last_left, first_right, init, op1, op2);
96 template<
typename Container1,
typename Container2,
typename T = value_type<Container1>>
97 T
distance(
const Container1& left,
const Container2& right, T init = T{})
99 assert(left.size() == right.size());
102 return distance(begin(left), end(left), begin(right), init);
108 template<
typename InputIterator1,
typename InputIterator2,
typename T = value_type_i<InputIterator1>>
109 T
squared_distance(InputIterator1 first_left, InputIterator1 last_left, InputIterator2 first_right, T init = T{})
111 const auto d =
distance(first_left, last_left, first_right, init);
119 template<
typename Container1,
typename Container2,
typename T = value_type<Container1>>
122 assert(left.size() == right.size());
T norm(const Container &a, T init=T{})
Definition: manhattan_space.hpp:46
T squared_norm(const Container &a, T init=T{})
Definition: manhattan_space.hpp:67
T squared_distance(const Container1 &left, const Container2 &right, T init=T{})
Definition: manhattan_space.hpp:120
T distance(const Container1 &left, const Container2 &right, T init=T{})
Definition: manhattan_space.hpp:97