Skip to main content

Mat

Type Alias Mat 

Source
pub type Mat<T, Rows = usize, Cols = usize> = Mat<Own<T, Rows, Cols>>;
Expand description

heap allocated resizable matrix, similar to a 2d alloc::vec::Vec

§note

the memory layout of Own is guaranteed to be column-major, meaning that it has a row stride of 1, and an unspecified column stride that can be queried with [Mat::col_stride]

this implies that while each individual column is stored contiguously in memory, the matrix as a whole may not necessarily be contiguous. the implementation may add padding at the end of each column when overaligning each column can provide a performance gain

let us consider a 3×4 matrix

 0 │ 3 │ 6 │  9
───┼───┼───┼───
 1 │ 4 │ 7 │ 10
───┼───┼───┼───
 2 │ 5 │ 8 │ 11

the memory representation of the data held by such a matrix could look like the following:

[0, 1, 2, x, 3, 4, 5, x, 6, 7, 8, x, 9, 10, 11, x]

where x represents padding elements

Aliased Type§

#[repr(transparent)]
pub struct Mat<T, Rows = usize, Cols = usize>(pub Own<T, Rows, Cols>);

Tuple Fields§

§0: Own<T, Rows, Cols>