Skip to main content

expand_subset_sums

Function expand_subset_sums 

Source
pub fn expand_subset_sums<P: PackedField>(elems: &[P]) -> Vec<P>
Expand description

Expands elems into all 2^elems.len() subset sums, indexed by subset bitmask.

The dynamically sized counterpart of expand_subset_sums_array, for callers whose element count is only known at run time. Entry mask holds the sum of elems[i] over every bit i set in mask, so entry 0 is zero and entry 2^i is elems[i].

Each entry costs one addition, where summing a subset directly would cost one per set bit.

ยงPreconditions

  • elems.len() must be less than usize::BITS