M4riTable

Struct M4riTable 

Source
pub(crate) struct M4riTable {
    rows: Vec<usize>,
    columns: Vec<LimbBitIndexPair>,
    data: Vec<u64>,
    min_limb: usize,
}
Expand description

M4RI works as follows — first row reduce k rows using the naive algorithm. We then construct a table of all 2^k linear combinations of these rows. This can be done in O(2^k) time. We then use this table to reduce the remaining rows, so that each row takes O(num_columns) time, which reduces the time taken by a factor of k x density.

Since we are likely to run into empty rows when doing row reduction, what we do in practice is that we keep reducing rows until we collect k of them. Whenever we find a row, we record it with M4riTable::add. We only record the row number and pivot column, as the values of these rows will change as we go on due to the desire to land in a RREF.

Once we have recorded enough rows, we generate the table using M4riTable::generate, and then reduce limbs using M4riTable::reduce. When we are done we clear it using M4riTable::clear and proceed to the next k rows.

Fields§

§rows: Vec<usize>

The indices of new rows in the table

§columns: Vec<LimbBitIndexPair>

The list of pivot columns of the rows

§data: Vec<u64>

The 2^k linear combinations of the k rows, apart from the first one which is identically zero.

§min_limb: usize

The smallest non-zero limb in this table. We use this when row reducing to save a few operations.

Implementations§

Source§

impl M4riTable

Source

pub fn new(k: usize, cols: usize) -> Self

Create a table with space for k vectors, each with cols columns.

Source

pub fn len(&self) -> usize

Number of rows in the M4riTable

Source

pub fn is_empty(&self) -> bool

Whether the table has no rows

Source

pub fn rows(&self) -> &[usize]

Get the list of pivot rows

Source

pub fn add(&mut self, column: usize, row: usize)

Add a row to the table.

§Arguments
  • column: pivot column of the row
  • row: index of the row
Source

pub fn clear(&mut self)

Clear the contents of the table

Source

pub fn generate(&mut self, matrix: &Matrix)

Generates the table from the known data num is the number of the vector being added.

Source

pub fn reduce_naive(&self, matrix: &mut Matrix, target: usize)

Source

pub fn reduce(&self, v: &mut [u64])

Trait Implementations§

Source§

impl Debug for M4riTable

Source§

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

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

impl Default for M4riTable

Source§

fn default() -> M4riTable

Returns the “default value” for a type. Read more

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.
§

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

§

fn vzip(self) -> V