Skip to content

add ordering (argsort) algorithm with caller-provided output#173

Open
correaa wants to merge 7 commits into
developfrom
ordering-algorithm
Open

add ordering (argsort) algorithm with caller-provided output#173
correaa wants to merge 7 commits into
developfrom
ordering-algorithm

Conversation

@correaa

@correaa correaa commented Jun 13, 2026

Copy link
Copy Markdown
Owner

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

alfC and others added 7 commits June 19, 2026 07:12
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>
@correaa correaa force-pushed the ordering-algorithm branch from bdbc80d to f36c551 Compare June 19, 2026 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants