ndarray-unit
:warning: This project is under active development and this README is using documentation comments that might be different than those uploaded on crates.io. Always check doc.rs for up-to-date documentation. :warning:
This crate provides a struct representing a multidimensionnal array together with a Unit
.
It allows to do computations taking into account the unit of your n-dimensional array.
Examples
use *;
extern crate ndarray;
use Array;
Output
// meter / second = m·s⁻¹
// arr_u3 = [[1, 0, 2, 6],
// [1, 2, 3, 5],
// [1, 2, 3, 6]] m
// ==========================================================
// [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40] m²·kg·s⁻²
// *[10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60] s
// =[300, 465, 640, 825, 1020, 1225, 1440, 1665, 1900, 2145, 2400] m²·kg·s⁻¹
// ==========================================================
// [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40] m²·kg·s⁻²
// /[10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60] s
// =[3, 2.0666, 1.6, 1.32, 1.1333, 1, 0.9, 0.8222, 0.76, 0.7090, 0.6666] m²·kg·s⁻³
// ==========================================================
// [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40] m²·kg·s⁻²
// +[30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40] m²·kg·s⁻²
// =[60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80] m²·kg·s⁻²
// ==========================================================
// [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60] s
// -[10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60] s
// =[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] s
// ==========================================================
Panics
The program will panic when you try to add or substract two ArrayUnit
s with different Unit
s.
extern crate ndarray;
use Array;
use *;
let arr1 = linspace;
let arr_u1 = new;
let arr2 = linspace;
let arr_u2 = new;
// let result = &arr_u1 + &arr_u2; // ==> panicking
Development
Doc of the master branch on github.io
Features
- Basic unit system handling multiplication and division
- ArrayUnit wrapper for unit + ndarray
- Operations on &ArrayUnit
- Mul/Div <&ArrayUnit>
- Add/Sub <&ArrayUnit> (now panicking if units are not equal, might change that in the future)
- Mul/Div with scalar
- Add/Sub with scalar
- Add prefix (mm, cm, dm, m, km)
- Basic ndarray function
- Transpose
- Rescale
- ...
Tests & Doc
- Basic unit system handling multiplication and division
- ArrayUnit wrapper for unit + ndarray
- Operations on &ArrayUnit
- Mul/Div <&ArrayUnit>
- Add/Sub <&ArrayUnit> (now panicking if units are not equal, might change that in the future)
- Mul/Div with scalar
- Add/Sub with scalar
- Add prefix (mm, cm, dm, m, km)
- Basic ndarray function
- Transpose
- Rescale
- ...