nthD_Matrix 0.1.2

A library for using matrixes of any arbitrary size and dimension
Documentation
  • Coverage
  • 0%
    0 out of 26 items documented0 out of 21 items with examples
  • Size
  • Source code size: 16.81 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 568.61 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • JamieH01

A simple library that allows you to use matrixes of any size and dimension, and access their internals as a regular old vector. NdMatrix provides a flexible data structure for any data, with basic arithmetic operations (thanks num_traits!). Check the Docs.md file on github for more info.

Matrixes can be initialized easily with the matrix! macro:

//dimensions, type, default
let matrix = matrix!([10,10,10]; usize, 15);

And then accessed with either coordinates or an absolute index into the vector:

let value1 = matrix.pos(vec![3,2,4])?;
let value2 = matrix.nth(15)?;

This setup makes iteration through a matrix straightforward, with no messy nested for loops:

for i in 0..matrix.len() {
    let pos:Vec<usize> = matrix.nth_to_pos(i)?;
    //do stuff with the position!
}

(iterators are a thing now too)

Basic arithmetic is also available for numeric types:

let mut matrix_a = matrix!([5,5]; usize, 10);
let matrix_b = matrix!([5,5]; usize, 10);

matrix_a.add(matrix_b);//adds 2 matrixes
matrix_a.const_add(15);//adds one value to every element of a matrix

add, sub, mul, and div can be called, along with their constant counterparts. Note that the 2 matrixes MUST be the same size, and mul is not the traditional "matrix multiplication," it simply multiplies each element together (coming soon).