[−][src]Macro const_linear::matrix
Constructs a matrix from a type, a value, or a series of values.
Examples
Identity matrix
An invocation in the form matrix![T; N]
creates an N x N identity matrix of type T
.
use const_linear::matrix; let expected = [1, 0, 0, 0, 1, 0, 0, 0, 1]; let m = matrix![i32; 3]; for (x, y) in m.column_iter().zip(expected.iter()) { assert_eq!(x, y); }
Matrix from value
An invocation in the form matrix![x; M, N]
creates
an M x N matrix filled with the value x
.
use const_linear::matrix; let expected = [1; 16]; let m = matrix![1; 4, 4]; for (x, y) in m.column_iter().zip(expected.iter()) { assert_eq!(x, y); }
Matrix from columns
An invocation in the form
matrix![
a, b, c, d, ...;
e, f, g, h, ...;
...
]
creates a matrix which has columns [a, b, c, d, ...], [e, f, g, h...], ...
A semicolon indicates the end of a column.
use const_linear::matrix; let m = matrix![ 1, 2, 3; 4, 5, 6; 7, 8, 9; ]; assert_eq!(m.det(), 0.0);