pub struct RowFoldTables<F, const N_TABLES: usize> { /* private fields */ }Expand description
Subset-sum tables for folding a matrix of single-bit rows against one weight per row.
The fold contracts the row axis, leaving one field element per column:
out[b] = sum_r weight[r] * bit_b(row[r])Taking eight rows at a time turns that inner sum into a single table lookup.
Table g covers rows 8g through 8g + 7 and holds every subset sum of their weights.
Implementations§
Source§impl<F: BinaryField, const N_TABLES: usize> RowFoldTables<F, N_TABLES>
impl<F: BinaryField, const N_TABLES: usize> RowFoldTables<F, N_TABLES>
Sourcepub fn new(weights: &[F]) -> Self
pub fn new(weights: &[F]) -> Self
Builds the tables from one weight per row, from the first row onwards.
Weights past the end of the slice read as zero. Those weight rows past the end of the matrix, which read as zero as well. So one table layout serves a chunk the row list does not fill.
Sourcepub fn fold_into<PB>(
&self,
groups: impl IntoIterator<Item = RowGroup<PB>>,
sums: &mut ColumnSums<F, N_TABLES>,
)
pub fn fold_into<PB>( &self, groups: impl IntoIterator<Item = RowGroup<PB>>, sums: &mut ColumnSums<F, N_TABLES>, )
Folds each group of eight rows into the column sums.
Groups pair with tables in order, so the gth group is weighted by rows 8g onwards.
An iterator yielding fewer groups leaves the remaining rows out, which reads them as zero.
§Preconditions
- A row must be one byte wide per table, so the groups cover every column exactly once.
Trait Implementations§
Auto Trait Implementations§
impl<F, const N_TABLES: usize> Freeze for RowFoldTables<F, N_TABLES>where
F: Freeze,
impl<F, const N_TABLES: usize> RefUnwindSafe for RowFoldTables<F, N_TABLES>where
F: RefUnwindSafe,
impl<F, const N_TABLES: usize> Send for RowFoldTables<F, N_TABLES>where
F: Send,
impl<F, const N_TABLES: usize> Sync for RowFoldTables<F, N_TABLES>where
F: Sync,
impl<F, const N_TABLES: usize> Unpin for RowFoldTables<F, N_TABLES>where
F: Unpin,
impl<F, const N_TABLES: usize> UnsafeUnpin for RowFoldTables<F, N_TABLES>where
F: UnsafeUnpin,
impl<F, const N_TABLES: usize> UnwindSafe for RowFoldTables<F, N_TABLES>where
F: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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