diff --git a/include/xtensor/xsort.hpp b/include/xtensor/xsort.hpp index e437edfa8..6a63ad48f 100644 --- a/include/xtensor/xsort.hpp +++ b/include/xtensor/xsort.hpp @@ -768,31 +768,6 @@ namespace xt using type = xtensor; }; - template - inline xtensor cmp_idx(IT iter, IT end, std::ptrdiff_t inc, F&& cmp) - { - std::size_t idx = 0; - auto min = *iter; - iter += inc; - for (std::size_t i = 1; iter < end; iter += inc, ++i) - { - if (cmp(*iter, min)) - { - min = *iter; - idx = i; - } - } - return xtensor{idx}; - } - - template - inline xtensor arg_func_impl(const E& e, F&& f) - { - return cmp_idx(e.template begin(), - e.template end(), 1, - std::forward(f)); - } - template inline typename argfunc_result_type::type arg_func_impl(const E& e, std::size_t axis, F&& cmp) @@ -804,7 +779,10 @@ namespace xt if (e.dimension() == 1) { - return arg_func_impl(e, std::forward(cmp)); + auto begin = e.template begin(); + auto end = e.template end(); + std::size_t i = std::distance(begin, std::min_element(begin, end)); + return xtensor{i}; } result_shape_type alt_shape;