-
Notifications
You must be signed in to change notification settings - Fork 2
FFT Processors Layouts
FFT and iFFT algorithms is carried-out in place on one of the FFT processors layouts: cplx
or reim
. The iFFT algorithm is non normalized, so if we run FFT then iFFT, one obtains
The cplx
and reim
layouts are both used to represent vectors of complex numbers; in the cplx
layout, each complex element is a contiguous pair of floats (float64[2]
), whereas in the reim
layout, we have one contiguous array of with all the real parts followed by one contiguous array with all the imaginary parts.
Given a complex polynomial
The complex coefficients of P are always presented in natural order
The fft vector of
where
By extension, if
The cplx layout is the classical representation for vector of complex numbers: one complex element is represented by the cplx = float64[2]
pair (real,imag)
. A vector of m
complex elements has layout cplx[m].
For a complex polynomial, the float64 coefficients are presented in order:
For a real polynomial, the float64 coefficients are presented in order:
Evaluations are in fracrevbits order described above, each complex evaluation comes as a (real,imag) pair.
In the reim layout, a vector of
When the reim layout is used to represent the coefficients of P, they are given in order
When the reim layout is used to represent the coefficients of a real polynomial P, they are given in the "friendly" order
As usual, FFT Evaluations are presented in the same fracrevbits order described above, the m real parts first, followed by the m imaginary parts.
In addition to the two FFT processors layouts, the library supports a few coefficients space layouts, that are convertible to and from cplx
/reim
.
Conversion between coefficient spaces and FFT-processor space are in general out-of-place.
Backwards conversion from reim/cplx
to a coefficient space contains an optional division (to renormalize the result after an iFFT) and a rounding (if the result is meant to be integer).
The rnx
layout represents the coefficients of a real polynomial mod X^N+1
in natural order as an array of N double-precision floats. This layout is in fact bitwise identical to the reim
layout, except that rnx
is usually parametrized by N
instead of m=N/2
.
The znx32
and znx64
layout represents the coefficients of an integer polynomial mod X^N+1
in natural order as an array of N
signed integers (of resp. 32 or 64 bits).
Forward conversions to reim/cplx
are exact from znx32
and retains at most 52 bits of precision for znx64
.
Backwards conversion require a static guarantee on the output interval: the programmer must guarantee that after the optional division and rounding, the result fits in an int32
if the destination is znx32
, and the programmer must provide an explicit bound if the destination is znx64
.
The tnx32
and tnx64
layouts represents the coefficients of an polynomial mod X^N+1
modulo 1 in natural order as an array of N
signed integers (of resp. 32 or 64 bits). For tnx32
, the a value tnx64
, the a value
Forward conversions to reim/cplx
are exact from tnx32
and retains at most 52 bits of precision for tnx64
.
Backwards conversion require a static guarantee by the programmer on the overhead (i.e. bound after the optional division): overhead <= 18 bits are efficient, an overhead of 20 bits can retain at most 32 bits of fractional precision, on the other hand, an overhead of 52 bits would lose all the bits and be completely useless.