crypto/ringlwe/FFT/FFT_512_25601.c
/*
We use Gentleman-Sande, decimation-in-frequency FFT, for the forward FFT.
We premultiply x by the 2n'th roots of unity to affect a Discrete Weighted Fourier Transform, 
so when we apply pointwise multiplication we obtain the negacyclic convolution, i.e. multiplication 
modulo x^n+1.
Note that we will not perform the usual scambling / bit-reversal procedure here because we will invert 
the fourier transform using decimation-in-time.
*/
We use Gentleman-Sande, decimation-in-frequency FFT, for the forward FFT.
We premultiply x by the 2n'th roots of unity to affect a Discrete Weighted Fourier Transform,
so when we apply pointwise multiplication we obtain the negacyclic convolution, i.e. multiplication
modulo x^n+1.
Note that we will not perform the usual scambling / bit-reversal procedure here because we will invert
the fourier transform using decimation-in-time.
We use Gentleman - Sande decimation - in - frequency FFT for the forward FFT . We premultiply x by the 2n ' th roots of unity to affect a Discrete Weighted Fourier Transform so when we apply pointwise multiplication we obtain the negacyclic convolution i . e . multiplication modulo x^n + 1 . Note that we will not perform the usual scambling / bit - reversal procedure here because we will invert the fourier transform using decimation - in - time .
void FFT_twisted_forward_512_25601(FFTSHORT x[512]) {
        const FFTSHORT n = 512;
        const FFTSHORT q = 25601;
	FFTSHORT index, step;
	FFTSHORT i,j,m;
	FFTSHORT t0,t1;
	j = 0;
	for (i = 0; i < n>>1; ++i) {
		MUL_MOD(x[j], x[j], W_512_25601[i], q);
		j++;	
		MUL_MOD(x[j], x[j], W_sqrt_512_25601[i], q);	
		j++;
	}
	step = 1;
	for (m = n>>1; m >= 1; m=m>>1) {
		index = 0;
		for (j = 0 ; j < m; ++j) {
			for (i = j; i < n; i += (m<<1)) {				
				ADD_MOD(t0, x[i], x[i+m], q);
				ADD(t1, x[i], q - x[i+m]);
				MUL_MOD(x[i+m], t1, W_512_25601[index], q);				
				x[i] = t0;						
			}
			SUB_MODn(index, index, step, n);
		}
		step = step << 1;
	}	 
}
void FFT_twisted_forward_512_25601 ( FFTSHORT x [ 512 ] ) { const FFTSHORT n = 512 ; const FFTSHORT q = 25601 ; FFTSHORT index , step ; FFTSHORT i , j , m ; FFTSHORT t0 , t1 ; j = 0 ; for ( i = 0 ; i < n >> 1 ; ++ i ) { MUL_MOD ( x [ j ] , x [ j ] , W_512_25601 [ i ] , q ) ; j ++ ; MUL_MOD ( x [ j ] , x [ j ] , W_sqrt_512_25601 [ i ] , q ) ; j ++ ; } step = 1 ; for ( m = n >> 1 ; m >= 1 ; m = m >> 1 ) { index = 0 ; for ( j = 0 ; j < m ; ++ j ) { for ( i = j ; i < n ; i += ( m << 1 ) ) { ADD_MOD ( t0 , x [ i ] , x [ i + m ] , q ) ; ADD ( t1 , x [ i ] , q - x [ i + m ] ) ; MUL_MOD ( x [ i + m ] , t1 , W_512_25601 [ index ] , q ) ; x [ i ] = t0 ; } SUB_MODn ( index , index , step , n ) ; } step = step << 1 ; } }
We use Gentleman-Sande, decimation-in-frequency FFT, for the forward FFT.
We use Gentleman - Sande decimation - in - frequency FFT for the forward FFT .
//Pre multiplication for twisted FFT