BinMatrix

Struct BinMatrix 

Source
pub struct BinMatrix { /* private fields */ }
Expand description

Structure to represent matrices

Implementations§

Source§

impl BinMatrix

Source

pub fn zero(rows: usize, cols: usize) -> BinMatrix

Create a zero matrix

Source

pub fn new(rows: Vec<BinVector>) -> BinMatrix

Create a new matrix

Source

pub fn from_slices<T: AsRef<[u64]>>(rows: &[T], rowlen: usize) -> BinMatrix

Create a new matrix from slices

Source

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

Source

pub fn random(rows: usize, columns: usize) -> BinMatrix

Construct a randomized matrix

Source

pub fn from_mzd(mzd: *mut Mzd) -> BinMatrix

Construct a BinMatrix from the raw mzd pointer

Source

pub fn identity(rows: usize) -> BinMatrix

Get an identity matrix

Source

pub fn augmented(&self, other: &BinMatrix) -> BinMatrix

Augment the matrix: [A] [B] => [A B]

Source

pub fn stacked(&self, other: &BinMatrix) -> BinMatrix

Stack the matrix with another and return the result

Source

pub fn rank(&self) -> usize

Get the rank of the matrix

Does an echelonization and throws it away!

Source

pub fn echelonize(&mut self) -> usize

Echelonize this matrix in-place

Return: the rank of the matrix

Source

pub fn inverted(&self) -> BinMatrix

Compute the inverse of this matrix, returns a new matrix

Source

pub fn transposed(&self) -> BinMatrix

Compute the transpose of the matrix

Source

pub fn nrows(&self) -> usize

Get the number of rows

O(1)

Source

pub fn ncols(&self) -> usize

Get the number of columns

O(1)

Source

pub fn get_word(&self, row: usize, column: usize) -> Word

Get a single word from the matrix at a certain offset

Source

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!

Source

pub fn get_word_mut(&self, row: usize, column: usize) -> &mut Word

Get a mutable reference to a particular word in the matrix

Source

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.

Source

pub fn as_vector(&self) -> BinVector

Get as a vector

Works both on single-column and single-row matrices

Source

pub fn bit(&self, row: usize, col: usize) -> bool

Get a certain bit

Source

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.

Source

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

Source

pub fn mul_slice(&self, other: &[u64]) -> BinMatrix

Multiply a matrix by a vector represented as a u64

Trait Implementations§

Source§

impl<'a> Add for &'a BinMatrix

Source§

fn add(self, other: &BinMatrix) -> Self::Output

Add up two matrices

Source§

type Output = BinMatrix

The resulting type after applying the + operator.
Source§

impl Add for BinMatrix

Source§

fn add(self, other: BinMatrix) -> Self::Output

Add up two matrices, re-uses memory of A

Source§

type Output = BinMatrix

The resulting type after applying the + operator.
Source§

impl<'a> AddAssign<&'a BinMatrix> for BinMatrix

Source§

fn add_assign(&mut self, other: &BinMatrix)

Add up two matrices, re-uses memory of A

Source§

impl AddAssign for BinMatrix

Source§

fn add_assign(&mut self, other: BinMatrix)

Add up two matrices, re-uses memory of A

Source§

impl Clone for BinMatrix

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BinMatrix

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for BinMatrix

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'a> Mul<&'a BinMatrix> for &'a BinVector

Source§

fn mul(self, other: &BinMatrix) -> Self::Output

computes v^T * A

Source§

type Output = BinVector

The resulting type after applying the * operator.
Source§

impl<'a> Mul<&'a BinVector> for &'a BinMatrix

Source§

fn mul(self, other: &BinVector) -> Self::Output

Computes (A * v^T)

Source§

type Output = BinVector

The resulting type after applying the * operator.
Source§

impl Mul<BinMatrix> for BinVector

Source§

fn mul(self, other: BinMatrix) -> Self::Output

computes v^T * A

Source§

type Output = BinVector

The resulting type after applying the * operator.
Source§

impl Mul<BinVector> for BinMatrix

Source§

fn mul(self, other: BinVector) -> Self::Output

Computes (A * v^T)

Source§

type Output = BinVector

The resulting type after applying the * operator.
Source§

impl<'a> Mul for &'a BinMatrix

Source§

fn mul(self, other: &BinMatrix) -> Self::Output

Computes the product of two matrices

Source§

type Output = BinMatrix

The resulting type after applying the * operator.
Source§

impl Mul for BinMatrix

Source§

fn mul(self, other: BinMatrix) -> Self::Output

Computes the product of two matrices

Source§

type Output = BinMatrix

The resulting type after applying the * operator.
Source§

impl PartialEq for BinMatrix

Source§

fn eq(&self, other: &BinMatrix) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for BinMatrix

Source§

impl Send for BinMatrix

Source§

impl Sync for BinMatrix

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V