macro_rules! matrix {
[$($e:expr),*] => { ... };
[ $($( $f:expr ),*);*] => { ... };
[$($( $f:expr) *);*] => { ... };
($e:expr => $f:expr) => { ... };
}
Expand description
Hels with matrix creation
examples:
use matrix_lib::*;
let m1 = matrix![[1,2,3], [4,5,6], [7,8,9]]; // each array provided in this macro is separate row
let m2 = matrix![1,2,3;4,5,6;7,8,9]; // rows are separated by semicolon `;`
let m3 = matrix![1 2 3; 4 5 6; 7 8 9]; // rows are separated by semicolon but with elements separated by space
let m4 = matrix!([1,2,3,4,5,6,7,8,9] => 3); // splits vectorized matrix into columns of matrix with 3 elements by each
assert_eq!(m1, m2);
assert_eq!(m2, m3);
assert_eq!(m4, matrix![[1, 4, 7], [2, 5, 8], [3, 6, 9]]);