Skip to content

feat: Hilbert keys of integer cells in 2D and 3D - #146

Merged
max-models merged 1 commit into
develfrom
claude/tree-d3d-poison-maxwell-atyjic
Nov 25, 2026
Merged

max-models merged 1 commit into
develfrom
claude/tree-d3d-poison-maxwell-atyjic

Conversation

@max-models

@max-models max-models commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

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 with morton_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.

@max-models
max-models merged commit e181269 into devel Nov 25, 2026
23 checks passed
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.

1 participant