Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make gini calculation serial only for now. #587

Merged
merged 1 commit into from
Mar 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions include/boost/math/statistics/univariate_statistics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,12 @@ inline auto median(RandomAccessContainer & v)
return median(std::execution::seq, std::begin(v), std::end(v));
}

#if 0
//
// Parallel gini calculation is curently broken, see:
// https://github.com/boostorg/math/issues/585
// We will fix this at a later date, for now just use a serial implementation:
//
template<class ExecutionPolicy, class RandomAccessIterator>
inline auto gini_coefficient(ExecutionPolicy&& exec, RandomAccessIterator first, RandomAccessIterator last)
{
Expand Down Expand Up @@ -445,6 +451,27 @@ inline auto gini_coefficient(ExecutionPolicy&& exec, RandomAccessIterator first,
return detail::gini_coefficient_parallel_impl<Real>(exec, first, last);
}
}
#else
template<class ExecutionPolicy, class RandomAccessIterator>
inline auto gini_coefficient(ExecutionPolicy&& exec, RandomAccessIterator first, RandomAccessIterator last)
{
using Real = typename std::iterator_traits<RandomAccessIterator>::value_type;

if (!std::is_sorted(exec, first, last))
{
std::sort(exec, first, last);
}

if constexpr (std::is_integral_v<Real>)
{
return detail::gini_coefficient_sequential_impl<double>(first, last);
}
else
{
return detail::gini_coefficient_sequential_impl<Real>(first, last);
}
}
#endif

template<class ExecutionPolicy, class RandomAccessContainer>
inline auto gini_coefficient(ExecutionPolicy&& exec, RandomAccessContainer & v)
Expand Down