macro_rules! matrix {
($( $( $x:expr ),* );* ) => { ... };
}
Expand description
Provides a concise syntax for creating Matrices of f64s, Creates a new Matrix, and adds every number seperated by a comma as a f64, and adds a new row for each semicolon. if rows are of unequal size, 0s are added to make up for the difference
ยงExamples
use matrix_mc::{matrix, Matrix};
let macro_matrix: Matrix = matrix!
[0, 1, 2;
1, 1;
2, 3, 4];
let manual_matrix: Matrix = {
let mut temp_matrix: Matrix = Vec::with_capacity(3);
let mut temp_vector: Vec<f64> = Vec::with_capacity(3);
temp_vector.push(0f64);
temp_vector.push(1f64);
temp_vector.push(2f64);
temp_matrix.push(temp_vector);
let mut temp_vector: Vec<f64> = Vec::with_capacity(3);
temp_vector.push(1f64);
temp_vector.push(1f64);
temp_vector.push(0f64);
temp_matrix.push(temp_vector);
let mut temp_vector: Vec<f64> = Vec::with_capacity(3);
temp_vector.push(2f64);
temp_vector.push(3f64);
temp_vector.push(4f64);
temp_matrix.push(temp_vector);
temp_matrix
};
assert_eq!(macro_matrix, manual_matrix);