MCPcopy Index your code
hub / github.com/becheran/fast-hilbert

github.com/becheran/fast-hilbert @v2.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.1.0 ↗ · + Follow
29 symbols 57 edges 4 files 5 documented · 17% updated 13d ago★ 603 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Fast Hilbert

Build Status doc crates.io usage license

Fast Hilbert 2D curve computation using an efficient Lookup Table (LUT) and only considering the lowest order for a given input.

h1 h2 h3 h4 h5 h6

  • Convert from discrete 2D space to 1D hilbert space and reverse
  • Generalized for different unsigned integer input types (thanks DoubleHyphen PR#3)
  • Speedup via lowest order computation (thanks DoubleHyphen PR#2)
  • Checked versions available on checked feature (thanks FeeFladder PR#21)
  • Very fast using an efficient 512 Byte LUT
  • No additional dependency

Benchmarking the conversion from full 256x256 discrete 2D space to the 1D hilbert space, shows that fast_hilbert more than twice as fast compared to the fastest 2D hilbert transformation libs written in rust. Benchmarked on a Intel i5-6400 CPU @ 2.70 GHz, 4 Cores with 8 GB RAM:

Library Time Description
fast_hilbert 0.7 ms Optimized for fast computation in 2D discrete space using an efficient LUT
hilbert_2d 2.5 ms Also allows other variants such as Moore and LIU
hilbert_curve 2.0 ms Implements algorithm described on Wikipedia
hilbert 32.1 ms Allows computation of higher dimensional Hilbert curves

Especially for higher orders fast_hilbert outperforms other libraries by using only the next lowest relevant order instead of computing the hilbert curve bit per bit for the given input. See PR #2 and #9 for more details.

For example the computation of xy2h(1, 2, 64) is very fast to compute using fast_hilbert compared to a higher x,y pair such as xy2h(u32::MAX-1, u32::MAX-2, 64):

Library x=1, y=2, order=64 x=u32::MAX-1, y=u32::MAX-2, order=64
fast_hilbert 4 ns 32 ns
hilbert_2d 73 ns 72 ns
hilbert_curve 67 ns 49 ns
hilbert 690 ns 680 ns

Extension points exported contracts — how you extend this code

Unsigned (Interface)
Unsigned integer input type which has a double value type as key [4 implementers]
src/lib.rs
UnsignedBase (Interface)
(no doc)
src/lib.rs

Core symbols most depended-on inside this repo

xy2h
called by 12
src/lib.rs
h2xy
called by 9
src/lib.rs
xy2h_checked
called by 3
src/checked.rs
draw_hilbert_curve
called by 1
src/lib.rs
max_coord
called by 1
src/checked.rs
max_index
called by 1
src/checked.rs
criterion_benchmark
called by 0
benches/benchmark.rs
criterion_benchmark
called by 0
benches/checked.rs

Shape

Function 25
Interface 2
Enum 1
Method 1

Languages

Rust100%

Modules by API surface

src/lib.rs15 symbols
src/checked.rs12 symbols
benches/checked.rs1 symbols
benches/benchmark.rs1 symbols

For agents

$ claude mcp add fast-hilbert \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page