Skip to content

A library for using matrixes of any arbitrary dimension

Notifications You must be signed in to change notification settings

JamieH01/NthD_Matrix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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).

About

A library for using matrixes of any arbitrary dimension

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages