Crate dimensionals

Source
Expand description

The Dimensionals library provides a multidimensional array implementation with a generic storage backend over a generic number type.

§Core Concepts

  • Element type T: The type of data stored in the array.
  • Storage backend S: The underlying storage mechanism for the array.
  • Number of dimensions N: The dimensionality of the array.

§Dimensional Types

  • Scalar: A 0-dimensional object, or just the element of type T itself.
  • Vector: A 1-dimensional array of elements with the type T.
  • Matrix: A 2-dimensional array of elements with the type T.
  • Tensor: An N-dimensional array of elements with the type T, where N > 2.

§Goals

The primary goal of this library is to provide a flexible and efficient way to work with multidimensional arrays of numeric types in Rust.

Using a generic storage backend, S, allows for different memory layouts and optimizations.

§Convenience Macros

The library provides convenience macros for creating arrays:

  • vector!: Creates a 1-dimensional array.
  • matrix!: Creates a 2-dimensional array.

§Example

use dimensionals::{matrix, vector, Dimensional, LinearArrayStorage};

// Create a vector
let v: Dimensional<i32, LinearArrayStorage<i32, 1>, 1> = vector![1, 2, 3, 4, 5];
assert_eq!(v[[0]], 1);

// Create a matrix
let m: Dimensional<f64, LinearArrayStorage<f64, 2>, 2> = matrix![
    [1.0, 2.0, 3.0],
    [4.0, 5.0, 6.0]
];
assert_eq!(m[[0, 0]], 1.0);
assert_eq!(m[[1, 1]], 5.0);

Macros§

matrix
Creates a 2-dimensional array (matrix).
vector
Creates a 1-dimensional array (vector).

Structs§

Dimensional
A multidimensional array type.
DimensionalIter
An iterator over the elements of a Dimensional array.
DimensionalIterMut
A mutable iterator over the elements of a Dimensional array.
LinearArrayStorage
A linear array storage backend for multidimensional arrays.

Traits§

DimensionalStorage
A trait for storage backends for multidimensional arrays.