Crates.io | dimensionals |
lib.rs | dimensionals |
version | 0.2.1 |
source | src |
created_at | 2024-06-14 21:42:50.0832 |
updated_at | 2024-06-20 22:52:40.983538 |
description | Rust native generic, flexible n-dimensional array. |
homepage | https://github.com/warlock-labs/dimensionals |
repository | https://github.com/warlock-labs/dimensionals |
max_upload_size | |
id | 1272415 |
size | 64,321 |
Dimensionals is a Rust library for working with n-dimensional data. It provides a flexible and efficient multidimensional array implementation with a generic storage backend.
The key motivations behind Dimensionals are:
std::ops
implementations for arithmetic operationsAdd this to your Cargo.toml
:
[dependencies]
dimensionals = "0.1.0"
Then, use the crate in your Rust code:
use dimensionals::{matrix, Dimensional, LinearArrayStorage};
fn main() {
let m: Dimensional<i32, LinearArrayStorage<i32, 2>, 2> = matrix![
[1, 2, 3],
[4, 5, 6]
];
assert_eq!(m[[0, 0]], 1);
assert_eq!(m[[1, 1]], 5);
}
For more examples and usage details, see the API documentation.
The following features and improvements are planned for future releases:
The LinearArrayStorage
backend stores elements in a contiguous Vec<T>
and computes element indices on the fly. This
provides good cache locality for traversals, but may not be optimal for sparse or very high dimensional arrays.
Alternative storage backends can be implemented by defining a type that implements the DimensionalStorage
trait.
Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests on the GitHub repository.
This project is licensed under the MIT License.
This project is inspired by and builds upon ideas from several existing multidimensional array libraries in Rust and other languages.
Warlock Labs - https://github.com/warlock-labs
Project Link: https://github.com/warlock-labs/dimensionals