Skip to content

Commit 1b61c4a

Browse files
author
Ιωάννης Νικολαΐδης
committed
Δημιουργία απαραιτήτων αρχείων
1 parent 8a55b7e commit 1b61c4a

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

README.md

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Lindel (lineariser-delineariser)
2+
3+
## Introduction
4+
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.
5+
6+
This crate is an extension of the `morton-encoding` crate.
7+
8+
## Getting started
9+
If it is not necessary to use `lindel` with `nalgebra`, it is sufficient to insert the line
10+
11+
```toml
12+
lindel = "1.0"
13+
```
14+
15+
under the `[dependencies]` section. Otherwise, the following section must be inserted to the project's `Cargo.toml` file:
16+
17+
```toml
18+
[dependencies.lindel]
19+
version = "1.0"
20+
features = ["nalgebra"]
21+
```
22+
23+
## Usage
24+
### Primitive integers
25+
```rust
26+
use lindel::*;
27+
let input = 99251;
28+
let output_1: [u8; 5] = hilbert_decode(input);
29+
let output_2: [u32; 2] = morton_decode(input);
30+
let input = [543u32, 23765];
31+
let output_1 = input.hilbert_index();
32+
let output_2 = input.z_index();
33+
```
34+
Please note the necessity of specifying the output data-types for the decoding operations.
35+
36+
### `Point`s:
37+
```rust
38+
use nalgebra::Point;
39+
use nalgebra::U4;
40+
use lindel::nalgebra_points::Lineariseable;
41+
type FourDees = Point<u32, U4>;
42+
let input = 26327612u128;
43+
let pnt = FourDees::from_z_index(input);
44+
let result = pnt.hilbert_index();
45+
```
46+
47+
### New large uints:
48+
49+
```rust
50+
lindel::create_lineariseable_data_type!(u128, 33, NewKey);
51+
let input = [870u128; 33];
52+
let hind = NewKey::hilbert_index(input);
53+
let zind = NewKey::z_index(input);
54+
let reinstated_input = hind.from_hilbert_index();
55+
assert_eq!(input, reinstated_input);
56+
let reinstated_input = NewKey::from_z_index(zind);
57+
assert_eq!(input, reinstated_input);
58+
```
59+
60+
## Advantages and Disadvantages
61+
Long story short: Choose Morton encoding (“z-indexing”) if speed is more important than locality. Otherwise, feel free to use Hilbert encoding everywhere.

0 commit comments

Comments
 (0)