Skip to main content

rs_eq_ind_from_factors

Function rs_eq_ind_from_factors 

Source
pub fn rs_eq_ind_from_factors<A, P>(
    alloc: &A,
    n: usize,
    eq_lo: &FieldBuffer<B128>,
    eq_hi: &FieldBuffer<B128>,
    row_batch_query: &FieldBuffer<B128>,
) -> FieldVec<P, A>
where A: Allocator, P: PackedField<Scalar = B128>,
Expand description

Builds the ring-switching equality indicator directly from the tensor’s two factors.

§Overview

The indicator is the suffix equality tensor, folded bitwise by the row-batching query. Expanding that tensor and then folding it would read and rewrite a whole 2^n buffer. This route produces each entry in one pass instead:

    out[hi << n_lo | lo] = fold(eq_lo[lo] * eq_hi[hi])

Entries at and above n are zero and are never computed.

The tensor expansion already costs one multiply per entry. So the fused product changes no operation count. It removes one full read pass and one full write pass over the 2^n buffer.

§Arguments

  • alloc - the allocator the returned indicator is drawn from
  • n - the number of leading entries computed; the rest are zero
  • eq_lo - the low tensor factor
  • eq_hi - the high tensor factor
  • row_batch_query - the vector every entry is folded bitwise by

§Preconditions

  • row_batch_query.len() must equal 128, the extension degree of B128 over B1
  • n <= 2^(eq_lo.log_len() + eq_hi.log_len())
  • A block must cover a whole number of packed elements, so the chunking below aligns. The exception is an output that fits inside one packed element, which is a single block.