Change evaluation domain API for cosets
Could the struct for an evaluation domain contain a Field element for the affine shift, which then enables it for use as any coset. This not existing required me to re-implement a subset of this logic. (The current API only supports cosets with shift g, for a subset of methods)
My suggested API:
- Have two constructors, one for the subgroup case, one for the coset case.
- Remove cosetFFT, instead have the FFTs switch "if affine_shift == Field::one()"
- Add coset support in the lagrange interpolations. This is simple to do (see libiop: https://github.com/alexchmit/libiop-dev/blob/master/libiop/algebra/lagrange.tcc#L177. I also suggest switching to its method of doing arithmetic as it avoids doing one more pass over the array, with the same number of arithmetic ops)
- Update the vanishing polynomial, this just requires setting the constant term to
affine_offset^|H|
Hmm these API changes do make the code more unified, but on the other hand it is nice to have a visual indicator that one is performing a coset FFT/IFFT. Do you have suggestions on how to get the best of both worlds?
I'm not really sure its useful to know if you're doing a coset FFT vs regular FFT. Are you worried about knowledge of the extra ~5% of runtime? If so, perhaps this difference can be made apparent in the traces. (Also this overhead decreases with nlog(d) FFTs)
I just mean from a code clarity perspective
Had a discussion with @Pratyush regarding an API for this.
- Make Domain have two constructors,
new_subgroup(subgroup_size)andnew_coset(coset_size, offset). - Remove cosetFFT / cosetIFFT methods
- Add a convenience method
domain.get_coset(offset), to make it easy to go from subgroup -> coset.
Are these changes still wanted? If so I'm happy to submit a pull request for this
Yes!