Function expand_subset_sums

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

Expands a slice of field elements into all possible subset sums.

For an input slice [a, b, c], this computes all possible sums of subsets: [0, a, b, a+b, c, a+c, b+c, a+b+c]

This is a dynamic version of expand_subset_sums_array that works with slices and returns a Vec with length 2^n where n is the input length.

§Arguments

  • elems - Input slice of field elements

§Returns

A Vec containing all possible subset sums of the input elements, with length 2^n where n is the length of the input slice.

§Example

let input = vec![F::ONE, F::from(2)];
let sums = expand_subset_sums(&input);
// sums = vec![F::ZERO, F::ONE, F::from(2), F::from(3)]