🏁 Data structures 🏁
GridArray and sliding window implementation used in DeepCausality.
The sliding window implementation over-allocates to trade space (memory) for time complexity by delaying the rewind operation when hitting the end of the underlying data structure. Specifically, a sliding window of size N can hold, without any array copy, approximately C-1 elements, where C is the total capacity defined as NxM with N as the window size and M as a multiple. This crate has two implementations, one over vector and the second over a const generic array. The const generic implementation is significantly faster than the vector-based version.
ArrayGrid is an abstraction over scalars, vectors, and low dimensional matrices similar to a tensor. In contrast to a tensor, an ArrayGrid is limited to low dimensions (1 to 4), only allowing a scalar, vector, or matrix type. Still, all of them are represented as a static fixed-size const generic array. Fixed-sized arrays allow for several compiler optimizations, including a cache-aligned data layout and the removal of runtime array boundary checks because all structural parameters are known upfront, providing a significant performance boost over tensors.
🤔 Why?
- Zero dependencies.
- Zero cost abstraction.
- Zero unsafe. 100% safe and fast Rust.
🚀 Install
Just run:
Alternatively, add the following to your Cargo.toml
= "0.4.2"
📚 Docs
⭐ Usage
See:
ArrayGrid
Important details:
- All const generic parameters are requires regardless of which ArrayType you are using
- To change the ArrayGrid type, just change the enum and your good.
- There are no array bounds checks past compilation, so its your job to ensure PointIndex does not exceed the Array boundaries.
use ;
// Consts dimensions requires for const generic paramaters
// Use these to check whether your PointIndex stays within the Array boundaries.
const WIDTH: usize = 5;
const HEIGHT: usize = 5;
const DEPTH: usize = 5;
const TIME: usize = 5;
SlidingWindow
Important details:
- ArrayStorage and VectorStorage have different signatures because only ArrayStorage requires const generics
- Size refers to the maximum number of elements the sliding window can store.
- Capacity refers to the maximum number of elements before a rewind occurs.
use ;
// Size refers to the maximum number of elements the sliding window can store.
const SIZE: usize = 4;
// Capacity refers to the maximum number of elements before a rewind occurs.
// Note, CAPACITY > SIZE and capacity should be a multiple of size.
// For example, size 4 should be stored 300 times before rewind;
// 4 * 300 = 1200
const CAPACITY: usize = 1200;
// Util function that helps with type inference.
🙏 Credits
The project took inspiration from:
👨💻👩💻 Contribution
Contributions are welcomed especially related to documentation, example code, and fixes. If unsure where to start, just open an issue and ask.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in deep_causality by you, shall be licensed under the MIT licence, without any additional terms or conditions.
📜 Licence
This project is licensed under the MIT license.
👮️ Security
For details about security, please read the security policy.
💻 Author
- Marvin Hansen.
- Github GPG key ID: 369D5A0B210D39BC
- GPG Fingerprint: 4B18 F7B2 04B9 7A72 967E 663E 369D 5A0B 210D 39BC