pub struct Matrix { /* private fields */ }Expand description
A dense binary matrix, every row a bitset of n_cols bits.
Implementations§
Source§impl Matrix
impl Matrix
Sourcepub fn from_rows(n_cols: usize, rows: &[Vec<usize>]) -> Matrix
pub fn from_rows(n_cols: usize, rows: &[Vec<usize>]) -> Matrix
The matrix of n_cols columns whose rows list the columns that hold a 1.
Sourcepub fn reduce(&mut self) -> Vec<usize>
pub fn reduce(&mut self) -> Vec<usize>
Reduced row echelon form in place, the pivots searched from the last column to the first: returns the pivot column of every leading row, in that order. The remaining rows are zero.
Sourcepub fn inverse(&self) -> Option<Matrix>
pub fn inverse(&self) -> Option<Matrix>
The inverse of a square matrix by Gauss–Jordan elimination, None if it is not
square or is singular.
§Examples
use comnum_math::gf2::Matrix;
// [[1, 1], [0, 1]] is its own inverse over GF(2)
let a = Matrix::from_rows(2, &[vec![0, 1], vec![1]]);
assert_eq!(a.inverse(), Some(a.clone()));
assert!(Matrix::from_rows(2, &[vec![0, 1], vec![0, 1]]).inverse().is_none());Trait Implementations§
impl Eq for Matrix
impl StructuralPartialEq for Matrix
Auto Trait Implementations§
impl Freeze for Matrix
impl RefUnwindSafe for Matrix
impl Send for Matrix
impl Sync for Matrix
impl Unpin for Matrix
impl UnsafeUnpin for Matrix
impl UnwindSafe for Matrix
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more