add ordering (argsort) algorithm with caller-provided output#173
Open
correaa wants to merge 7 commits into
Open
add ordering (argsort) algorithm with caller-provided output#173correaa wants to merge 7 commits into
correaa wants to merge 7 commits into
Conversation
ordering() writes the index permutation that sorts a 1D range without moving the data; output goes into a caller-provided random-access range (no internal allocation). Adds test/ordering.cpp. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…fers std::sort inlined over a compile-time-sized std::array<,3> trips gcc's -Warray-bounds (introsort's threshold-16 path is dead but flagged at -O3). Use multi::array output buffers (and data_elements() for the pointer case) which gcc cannot bound, so the false positive disappears. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
dst[k] = src[order[k]]; no internal allocation, src untouched. Works for N-dimensional src (gathers whole slices), enabling e.g. reordering the rows of a matrix by an order computed from a separate key column. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…t::algorithm::apply_permutation Applying an ordering needs no dedicated function: gather is a std::transform over the index range (or a lazy views::transform), and in-place reordering is boost::algorithm::apply_permutation. Document both idioms in the header instead. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…olicy overloads Stop hard-coding std::sort. Dispatch the sort through ADL with a std::sort fallback (priority_tag), so thrust::sort is used automatically for thrust iterators without ambiguity (a plain 'using std::sort' would tie with the same-signature thrust::sort). Add overloads taking an execution policy as the first argument (std::execution::par, or a thrust policy), disambiguated via a has_extension trait. Seeding stays a qualified std::copy to keep the ADL surface to just the sort. Verified locally against real thrust (CPP backend), std policies, and the std/pointer fallback. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…xecution std::execution::seq broke nvcc/nvhpc (header guarded out yet __cpp_lib_execution still defined) and IWYU (demanded internal <pstl/...> headers). Replace with a tiny user-defined policy whose ADL-found sort exercises the policy overload and the ADL-preferred dispatch path directly, with no <execution>/TBB dependency. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
bdbc80d to
f36c551
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ordering() writes the index permutation that sorts a 1D range without
moving the data; output goes into a caller-provided random-access range
(no internal allocation). Adds test/ordering.cpp.
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com