pub struct WordAxisFolder<F: BinaryField> { /* private fields */ }Expand description
A reusable Method of Four Russians folder over a fixed evaluation point, contracting the word axis.
Many word-lists often share one point, so the tables are built once here and reused. The batched instance fold is that case: every committed word folds against the same point.
The two tables it holds:
- per-byte subset-sum lookups, built from the point’s prefix.
- one weight per chunk, built from the point’s suffix.
Implementations§
Source§impl<F: BinaryField> WordAxisFolder<F>
impl<F: BinaryField> WordAxisFolder<F>
Sourcepub fn new(point: &[F]) -> Self
pub fn new(point: &[F]) -> Self
Builds the folding tables for point.
Each later fold takes a list of at most 2^point.len() words, folded against
this point.
Sourcepub fn fold(&self, words: &[Word]) -> FoldedWord<F>
pub fn fold(&self, words: &[Word]) -> FoldedWord<F>
Folds one word-list against the point.
Returns the array whose entry at bit position b is
out[b] = sum_i eq(point, i) * bit_b(words[i])with a clear bit read as zero and a set bit read as one.
This runs sequentially over the list’s chunks, so it leaves every other core free. It is the right driver for a caller already parallel over many lists. A caller with few lists wants the parallel driver below instead.
A list shorter than the word axis reads its missing high rows as zero: an absent row’s weight multiplies nothing, so it contributes nothing to any bit position. Chunks lying entirely past the list’s end are therefore never visited at all.
§Preconditions
words.len() <= 1 << point.len()
Sourcepub fn fold_par(&self, words: &[Word]) -> FoldedWord<F>
pub fn fold_par(&self, words: &[Word]) -> FoldedWord<F>
Folds one word-list against the point, parallel over that list’s chunks.
Returns the same array the sequential fold returns, under the same contract. The two differ only in how the chunk axis is divided across workers.
Reach for this when few lists share the point, so the chunk axis is the only one wide enough to divide. A caller folding many lists against one point should instead parallelize across the lists and fold each one sequentially.
§Preconditions
words.len() <= 1 << point.len()
Trait Implementations§
Auto Trait Implementations§
impl<F> Freeze for WordAxisFolder<F>
impl<F> RefUnwindSafe for WordAxisFolder<F>
impl<F> Send for WordAxisFolder<F>
impl<F> Sync for WordAxisFolder<F>
impl<F> Unpin for WordAxisFolder<F>
impl<F> UnsafeUnpin for WordAxisFolder<F>
impl<F> UnwindSafe for WordAxisFolder<F>
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
§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