Skip to main content

Module fold_word

Module fold_word 

Source
Expand description

Contracting a word list against weights, along either of its two axes.

A &[Word] list is a matrix over GF(2): row i is word i, and column b is bit position b across every word.

    words[0]  b63 b62 ... b1 b0
    words[1]  b63 b62 ... b1 b0
      ...
    words[n]  b63 b62 ... b1 b0

Every fold here contracts one axis of that matrix against one weight per position of it.

contractsweightsleaves
the bit axis, the columnsone per bit positionone element per word
the word axis, the rowsan equality tensor over the rowsone element per bit position

Both use the Method of Four Russians: group eight weights, precompute all 256 of their subset sums, then let one byte of the matrix index eight positions’ whole contribution at once.

The two directions differ in one step. Folding the bit axis reads a byte of the word directly. Folding the word axis first transposes a group of eight rows, so that one byte carries eight rows’ bits at a single column.

Each axis is folded through a folder that owns its lookup tables. Building the folder is what costs, so a caller folding several lists against one point builds it once and reuses it.

Structs§

BitAxisFolder
A reusable folder over a fixed vector of bit-index scalars.
WordAxisFolder
A reusable Method of Four Russians folder over a fixed evaluation point, contracting the word axis.

Type Aliases§

FoldedWord
One 64-bit word with its bit axis expanded into full field elements.