pub struct BinMatrix { /* private fields */ }
Expand description
Structure to represent matrices
Implementations§
Source§impl BinMatrix
impl BinMatrix
Sourcepub fn from_slices<T: AsRef<[u64]>>(rows: &[T], rowlen: usize) -> BinMatrix
pub fn from_slices<T: AsRef<[u64]>>(rows: &[T], rowlen: usize) -> BinMatrix
Create a new matrix from slices
Sourcepub fn count_ones(&self) -> u32
pub fn count_ones(&self) -> u32
Get the hamming weight for single-row or single-column matrices (ie. vectors)
Panics if nrows > 1 && ncols > 1
Sourcepub fn stacked(&self, other: &BinMatrix) -> BinMatrix
pub fn stacked(&self, other: &BinMatrix) -> BinMatrix
Stack the matrix with another and return the result
Sourcepub fn rank(&self) -> usize
pub fn rank(&self) -> usize
Get the rank of the matrix
Does an echelonization and throws it away!
Sourcepub fn echelonize(&mut self) -> usize
pub fn echelonize(&mut self) -> usize
Echelonize this matrix in-place
Return: the rank of the matrix
Sourcepub fn transposed(&self) -> BinMatrix
pub fn transposed(&self) -> BinMatrix
Compute the transpose of the matrix
Sourcepub fn get_word(&self, row: usize, column: usize) -> Word
pub fn get_word(&self, row: usize, column: usize) -> Word
Get a single word from the matrix at a certain offset
Sourcepub unsafe fn get_word_unchecked(&self, row: usize, column: usize) -> Word
pub unsafe fn get_word_unchecked(&self, row: usize, column: usize) -> Word
Get a particular word from the matrix Does not do any bounds checking!
Sourcepub fn get_word_mut(&self, row: usize, column: usize) -> &mut Word
pub fn get_word_mut(&self, row: usize, column: usize) -> &mut Word
Get a mutable reference to a particular word in the matrix
Sourcepub unsafe fn get_word_mut_unchecked(
&self,
row: usize,
column: usize,
) -> &mut Word
pub unsafe fn get_word_mut_unchecked( &self, row: usize, column: usize, ) -> &mut Word
Get a mutable reference to a particular word in the matrix without bounds checking.
Sourcepub fn as_vector(&self) -> BinVector
pub fn as_vector(&self) -> BinVector
Get as a vector
Works both on single-column and single-row matrices
Sourcepub fn get_window(
&self,
start_row: usize,
start_col: usize,
high_row: usize,
high_col: usize,
) -> BinMatrix
pub fn get_window( &self, start_row: usize, start_col: usize, high_row: usize, high_col: usize, ) -> BinMatrix
Get a window from the matrix. Makes a copy.
Sourcepub fn set_window(
&mut self,
start_row: usize,
start_col: usize,
other: &BinMatrix,
)
pub fn set_window( &mut self, start_row: usize, start_col: usize, other: &BinMatrix, )
Set a window in the matrix to another matrix
Currently does bit-by-bit, should use more optimal means if alignment allows it
Trait Implementations§
Source§impl<'a> AddAssign<&'a BinMatrix> for BinMatrix
impl<'a> AddAssign<&'a BinMatrix> for BinMatrix
Source§fn add_assign(&mut self, other: &BinMatrix)
fn add_assign(&mut self, other: &BinMatrix)
Add up two matrices, re-uses memory of A
Source§impl AddAssign for BinMatrix
impl AddAssign for BinMatrix
Source§fn add_assign(&mut self, other: BinMatrix)
fn add_assign(&mut self, other: BinMatrix)
Add up two matrices, re-uses memory of A