6 * Determines the twiddle factor of this 2-point FFT based on the
7 * indices of the process.
9 void fft2_init(DOLProcess *p)
11 const float PI = 2.0 * asin(1.0);
12 int layer_index = GETINDEX(0);
13 int process_index = GETINDEX(1);
14 float exponent = 2.0 * PI *
15 (float)(process_index % (1 << layer_index)) /
16 (float)(1 << (layer_index + 1));
18 sprintf(p->local->id, "FFT2_%d_%d",
21 p->local->twiddle_factor.real = cos(exponent);
22 p->local->twiddle_factor.imag = -sin(exponent);
24 printf("%15s: twiddle_factor %9f + j * %9f\n",
26 p->local->twiddle_factor.real,
27 p->local->twiddle_factor.imag);
31 * Computes 2-point FFT.
33 int fft2_fire(DOLProcess *p)
35 DOL_read((void*)PORT_INA, &(p->local->inA), sizeof(ComplexNumber), p);
36 DOL_read((void*)PORT_INB, &(p->local->inB), sizeof(ComplexNumber), p);
38 p->local->rotated_inB.real = p->local->inB.real
39 * p->local->twiddle_factor.real
41 * p->local->twiddle_factor.imag ;
42 p->local->rotated_inB.imag = p->local->inB.real
43 * p->local->twiddle_factor.imag
45 * p->local->twiddle_factor.real;
47 p->local->outA.real = p->local->inA.real
48 + p->local->rotated_inB.real;
49 p->local->outA.imag = p->local->inA.imag
50 + p->local->rotated_inB.imag;
52 p->local->outB.real = p->local->inA.real
53 - p->local->rotated_inB.real;
54 p->local->outB.imag = p->local->inA.imag
55 - p->local->rotated_inB.imag;
57 DOL_write((void*)PORT_OUTA, &(p->local->outA), sizeof(ComplexNumber), p);
58 DOL_write((void*)PORT_OUTB, &(p->local->outB), sizeof(ComplexNumber), p);
61 printf("%15s: ", p->local->id);
62 printf("%9f + j * %9f, %9f + j * %9f => %9f + j * %9f, %9f + j * %9f\n",