algebra icon indicating copy to clipboard operation
algebra copied to clipboard

Change evaluation domain API for cosets

Open ValarDragon opened this issue 6 years ago • 4 comments

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|

ValarDragon avatar Feb 01 '20 05:02 ValarDragon

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?

Pratyush avatar Feb 03 '20 10:02 Pratyush

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)

ValarDragon avatar Feb 03 '20 17:02 ValarDragon

I just mean from a code clarity perspective

Pratyush avatar Feb 03 '20 17:02 Pratyush

Had a discussion with @Pratyush regarding an API for this.

  1. Make Domain have two constructors, new_subgroup(subgroup_size) and new_coset(coset_size, offset).
  2. Remove cosetFFT / cosetIFFT methods
  3. Add a convenience method domain.get_coset(offset), to make it easy to go from subgroup -> coset.

ValarDragon avatar Nov 27 '20 19:11 ValarDragon

Are these changes still wanted? If so I'm happy to submit a pull request for this

andrewmilson avatar Sep 24 '22 23:09 andrewmilson

Yes!

Pratyush avatar Sep 25 '22 00:09 Pratyush