Lindel (lineariser-delineariser)
Introduction
The lindel crate offers functions for transforming arrays of primitive unsigned integers to Morton or Hilbert keys and back, via the eponymous encoding processes. This helps linearise data points while preserving some measure of locality.
This crate is an extension of the morton-encoding crate.
Getting started
If it is not necessary to use lindel with nalgebra, it is sufficient to insert the line
= "0.1"
under the [dependencies] section. Otherwise, the following section must be inserted to the project's Cargo.toml file:
[]
= "0.1"
= ["nalgebra"]
Usage
Primitive integers
use *;
let input = 99251;
let output_1: = hilbert_decode;
let output_2: = morton_decode;
let input = ;
let output_1 = input.hilbert_index;
let output_2 = input.z_index;
Please note the necessity of specifying the output data-types for the decoding operations.
Points:
use Point;
use U4;
use Lineariseable;
type FourDees = ;
let input = 26327612u128;
let pnt = from_z_index;
let result = pnt.hilbert_index;
New large uints:
create_lineariseable_data_type!;
let input = ;
let hind = hilbert_index;
let zind = z_index;
let reinstated_input = hind.from_hilbert_index;
assert_eq!;
let reinstated_input = from_z_index;
assert_eq!;
Advantages and Disadvantages
Long story short: Choose Morton encoding (“z-indexing”) if speed is more important than locality. Otherwise, feel free to use Hilbert encoding everywhere.