| Crates.io | dilate |
| lib.rs | dilate |
| version | 0.6.3 |
| created_at | 2022-02-24 15:17:29.00337+00 |
| updated_at | 2024-05-05 13:32:20.735018+00 |
| description | A compact, high performance integer dilation library for Rust. |
| homepage | https://github.com/alexmadeathing/dilate |
| repository | https://github.com/alexmadeathing/dilate |
| max_upload_size | |
| id | 538580 |
| size | 153,066 |
This library is in an alpha stage of development. It is feature complete at a basic level, its interface may be subject to change.
For migration notes, please see: https://github.com/alexmadeathing/dilate/releases
A compact, high performance integer dilation library for Rust.
Integer dilation is the process of converting cartesian indices (eg.
coordinates) into a format suitable for use in D-dimensional algorithms
such Morton Order curves.
The dilation process takes an integer's bit sequence and inserts a number
of 0 bits (D - 1) between each original bit successively. Thus, the
original bit sequence becomes evenly padded. For example:
0b1101 D2-dilated becomes 0b10100010b1011 D3-dilated becomes 0b1000001001The process of undilation, or 'contraction', does the opposite:
0b1010001 D2-undilated becomes 0b11010b1000001001 D3-undilated becomes 0b1011This libary also supports a limited subset of arthimetic operations on dilated integers via the standard rust operater traits. Whilst slightly more involved than regular integer arithmetic, these operations are still highly performant.
For more information on the supported dilations and possible type combinations, please see Supported Dilations via Expand and Supported Dilations via Fixed.
u8, u16, u32, u64, u128, usize)no_std - Suitable for embedded devices (additional standard library features can be enabled via the std feature)First, link dilate into your project's cargo.toml.
Check for the latest version at crates.io:
[dependencies]
dilate = "0.6.3"
# dilate = { version = "0.6.3", features = ["std"] } <- For std features like Add, Sub and Display
Next, import dilate into your project and try out some of the features:
use dilate::*;
let original: u8 = 0b1101;
// Dilating
let dilated = original.dilate_expand::<2>();
assert_eq!(dilated.value(), 0b1010001);
// This is the actual dilated type
assert_eq!(dilated, DilatedInt::<Expand<u8, 2>>(0b1010001));
// Undilating
assert_eq!(dilated.undilate(), original);
Example 2-dilation and undilation usage
use dilate::*;
let original: u8 = 0b1011;
// Dilating
let dilated = original.dilate_expand::<3>();
assert_eq!(dilated.value(), 0b1000001001);
// This is the actual dilated type
assert_eq!(dilated, DilatedInt::<Expand<u8, 3>>(0b1000001001));
// Undilating
assert_eq!(dilated.undilate(), original);
Example 3-dilation and undilation usage
For more detailed info, please see the code reference.
Please refer to the Roadmap to V1.0 discussion.
Contributions are most welcome.
For bugs reports, please submit a bug report.
For feature requests, please submit a feature request.
If you have ideas and want to contribute directly, pull requests are most welcome. If it's a small change just submit a pull request. If you're planning a large or breaking change, please create an Idea discussion in the discussions area so that we can reach a concensus.
Many thanks to the authors of the following white papers:
Permission has been explicitly granted to reproduce the agorithms within each paper.
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.