Repository navigation
feat: Hilbert keys of integer cells in 2D and 3D - #146
Merged
Merged
Conversation
4 tasks done
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.
xp.algorithms.hilbert_encode(*cells, levels=...)returns the position of integer cells along a Hilbert curve, in 2D and 3D, on NumPy or CuPy. It uses Skilling's construction ("Programming the Hilbert curve", 2004): the coordinates are transformed with array operations over all points, then their bits are interleaved withmorton_encode(axis 0 is the highest bit of each group).Unlike the Morton curve, consecutive keys are always face-neighbouring cells, and the cells of every quadtree or octree node are still a contiguous range. So pieces of a curve cut into equal parts stay compact. patchwork will use it to place patches on ranks.
Tests check that the keys are a permutation of all cells, that consecutive keys share a face (2D up to 5 levels, 3D up to 3), that the first level is the U through (0,0), (0,1), (1,1), (1,0), that quadtree nodes map to contiguous ranges, and the argument checks.