feat(numerics): add branchless 2D/3D Hilbert curve Radix sort - #61
Merged
Merged
Conversation
Introduces a 4-pass 16-bit LSD Radix sort backend for sorting complex coordinates along a continuous Hilbert space-filling curve. Implementation details: - Implements `sort_complex_hilbert` with a single O(N) auxiliary payload buffer. - Adds branchless 2D Hilbert encoding using SWAR bit-parallel Gray code transformations. - Implements a 24-state SO(3) octahedral rotation lookup table for 3D state transitions. - Uses strict bitwise math for monotonic IEEE-754 single and double precision conversion. - Integrates `HilbertSort` wrapper complying with `SortAlgorithm` registry standard. Fixes #33
🎉 Welcome, @Sambit003! |
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.
Pull Request
Description
Introduces a 4-pass 16-bit LSD Radix sort backend for sorting complex coordinates along a continuous Hilbert space-filling curve.
This PR addresses the need for a highly optimized, locality-preserving multidimensional sorting mechanism without recursive overhead. By leveraging branchless bit-parallel Gray code transformations for Hilbert encoding and mapping the coordinates to an$O(N)$ contiguous auxiliary buffer, we ensure strictly monotonic ordering across both single and double precision floats while avoiding branch mispredictions and dynamic allocations during the scatter passes.
Fixes #33
Type of Change
feat: New algorithm, heuristic, or capabilityfix: Bug fixperf: Performance optimizationrefactor: Code refactoring without behavioral changedocs: Documentation addition or updateenhance: Incremental enhancement to existing featuretest: New or updated testschore: Build system, CI, dependencies, or toolingImplementation Details
Payloadbuffer allocated once)IntroSortfor segments under 256 elements to prevent buffer allocation overhead on small inputs.Benchmarks & Performance Metrics (if applicable)
N/A - Formal benchmark regression analysis pending in follow-up profiling.
Dependencies
None
Testing & Verification
ctest --preset debugorctest --test-dir build --output-on-failure)pytest tests/python/ -v)cmake --preset asan)RapidCheck Property-Based Tests (HilbertSortPBT)Developer Checklist
<Type>(<scope>): <Precise PR deliverable>.mainusing an approved prefix (feat/,fix/,perf/, etc.).clang-format.clang-tidy).Impact Assessment
Future Improvements
Potential integration with$SO(3)$ table lookups for 3D coordinates.
simdvectorized routines to parallelize the 24-stateAdditional Notes
None