Struct dense_mats::StridedMat
[−]
[src]
pub struct StridedMat<N, Storage> where Storage: Deref<Target=[N]> {
// some fields omitted
}
A simple dense matrix
Methods
impl<N> StridedMat<N, Vec<N>>
fn new_owned(data: Vec<N>, rows: usize, cols: usize, strides: [usize; 2]) -> StridedMatOwned<N>
Create a dense matrix from owned data
fn zeros(rows: usize, cols: usize, order: StorageOrder) -> StridedMatOwned<N> where N: Num + Copy
Create an all-zero dense matrix
impl<'a, N> StridedMat<N, &'a [N]>
fn new_borrowed(data: &'a [N], rows: usize, cols: usize, strides: [usize; 2]) -> StridedMatView<'a, N> where N: 'a
Create a view of a matrix implementing DenseMatView
impl<N, Storage> StridedMat<N, Storage> where Storage: Deref<Target=[N]>
fn rows(&self) -> usize
The number of rows of the matrix
fn cols(&self) -> usize
The number of cols of the matrix
fn strides(&self) -> [usize; 2]
The strides of the matrix.
self.strides()[0] gives the number of elements that must be skipped into self.data() to get to the element of the next row with the same column. self.strides()[1] gives the number of elements that must be skipped into self.data() to get to the element of the next column with the same row.
For a row major matrix of shape (3, 4) with contiguous storage, the strides would be [4, 1].
For alignement reasons, it is possible to have strides that don't match the shape of the matrix (meaning that some elements of the data array are unused).
fn data(&self) -> &[N]
Access to the matrix's data
Getting access to the element located at row i and column j can be done by indexing self.data() at the location computed by i * strides[0] + j * strides[1]
fn shape(&self) -> [usize; 2]
The number of rows and cols of the matrix
fn ordering(&self) -> StorageOrder
Storage order. Specifies which dimension is stored the most contiguously in memory
fn data_index(&self, i: usize, j: usize) -> usize
Give the index into self.data() for accessing the element at row i and column j
fn row(&self, i: usize) -> Result<StridedVecView<N>, DMatError>
Get a view into the specified row
fn col(&self, j: usize) -> Result<StridedVecView<N>, DMatError>
Get a view into the specified column
impl<N, Storage> StridedMat<N, Storage> where Storage: DerefMut<Target=[N]>
fn data_mut(&mut self) -> &mut [N]
Mutable access to the matrix's data
Getting access to the element located at row i and column j can be done by indexing self.data() at the location computed by i * strides[0] + j * strides[1]
fn row_mut(&mut self, i: usize) -> Result<StridedVecViewMut<N>, DMatError>
Get a mutable view into the specified row
fn col_mut(&mut self, j: usize) -> Result<StridedVecViewMut<N>, DMatError>
Get a mutable view into the specified column