Twiddles
This section provides a detailed look at how twiddles are computed and stored in S-two.As discussed earlier, S-two has two main backend implementations:
CpuBackend and SimdBackend. Each backend implements the PolyOps trait, which provides core polynomial operations such as interpolation, evaluation and twiddle precomputation. Here and in the following sections on Circle FFT, we will explore how these functions are implemented for the CpuBackend.Twiddle Tree
The twiddles are stored using theTwiddleTree struct implemented as follows:
CpuBackend, B::Twiddles is a vector of BaseField elements. Here, root_coset is the half coset of our circle domain . As we have seen in the earlier section, for interpolation we divide by twiddles or multiply by inverse twiddles. In the evaluation algorithm, we multiply by twiddles. Thus we store both twiddles and their inverses itwiddles.
Now we will understand how the twiddle tree is computed using an example. Consider the following half coset of a circle domain .
TwiddleTree is constructed by the precompute_twiddles function, which takes the half coset as input and produces the twiddles needed to perform FFT over the corresponding circle domain. It is implemented as follows:
twiddles using the function slow_precompute_twiddles then computes their inverses itwiddles using batch inversion and finally stores them in the TwiddleTree along with the root_coset which is the input half coset.
Now let us look into the function slow_precompute_twiddles.
precompute_twiddles will output TwiddleTree with twiddles as and itwiddles as . The twiddles will be used for the evaluation algorithm and itwiddles will be used for the interpolation algorithm.
In the next section, we will bring together everything we’ve covered so far on Circle FFT to examine the implementation of the interpolation algorithm.