[][src]Macro crabsformer::matrix

macro_rules! matrix {
    ($elem:expr; $shape:expr) => { ... };
    ($($x:expr),*) => { ... };
    ($($x:expr,)*) => { ... };
    ($($($x:expr),*;)*) => { ... };
    ($($($x:expr),*);*) => { ... };
}

Creates a matrix containing the arguments.

matrix! allows matrix to be defined with the same syntax as array expressions.

There are two forms of this macro:

  1. Create a matrix containing a given list of elements:
let w = matrix![
    3, 1, 4;
    1, 5, 9;
];
assert_eq!(w[0][0], 3);
assert_eq!(w[0][1], 1);
assert_eq!(w[0][2], 4);
assert_eq!(w[1][0], 1);
assert_eq!(w[1][1], 5);
assert_eq!(w[1][2], 9);
  1. Create a matrix from a given element and shape:
let w = matrix![1; [3, 3]];
assert_eq!(w, matrix![
    1, 1, 1;
    1, 1, 1;
    1, 1, 1;
]);