summaryrefslogtreecommitdiff
path: root/test/c/fftw.c
blob: 0b4149568ffb2e8716632a86eb243ef7ced264a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* FFT test generated by FFTW */

#include <stdio.h>

typedef long int INT;
typedef double R;
typedef R E;
typedef INT *stride;

/* Generated by: ../../../genfft/gen_r2r.native -compact -variables 4 -pipeline-
latency 4 -redft01 -n 8 -name e01_8 -include r2r.h */
void e01_8(const R *I, R *O, stride is, stride os, INT v, INT ivs, INT ovs)
{
const E KP1_662939224 = ((E) +1.662939224605090474157576755235811513477121624);
const E KP1_111140466 = ((E) +1.111140466039204449485661627897065748749874382);
const E KP390180644 = ((E) +0.390180644032256535696569736954044481855383236);
const E KP1_961570560 = ((E) +1.961570560806460898252364472268478073947867462);
const E KP707106781 = ((E) +0.707106781186547524400844362104849039284835938);
const E KP1_414213562 = ((E) +1.414213562373095048801688724209698078569671875);
const E KP765366864 = ((E) +0.765366864730179543456919968060797733522689125);
const E KP1_847759065 = ((E) +1.847759065022573512256366378793576573644833252);
  INT i;
  for (i = v; i > 0; i = i - 1, I = I + ivs, O = O + ovs) {
    E T7, Tl, T4, Tk, Td, To, Tg, Tn;
    {
      E T5, T6, T1, T3, T2;
      T5 = I[(is[2])];
      T6 = I[(is[6])];
      T7 = (((KP1_847759065) * (T5)) + (KP765366864 * T6));
      Tl = ((KP765366864 * T5) - ((KP1_847759065) * (T6)));
      T1 = I[0];
      T2 = I[(is[4])];
      T3 = KP1_414213562 * T2;
      T4 = T1 + T3;
      Tk = T1 - T3;
      {
    E T9, Tf, Tc, Te, Ta, Tb;
    T9 = I[(is[1])];
    Tf = I[(is[7])];
    Ta = I[(is[5])];
    Tb = I[(is[3])];
    Tc = KP707106781 * (Ta + Tb);
    Te = KP707106781 * (Ta - Tb);
    Td = T9 + Tc;
    To = Te + Tf;
    Tg = Te - Tf;
    Tn = T9 - Tc;
      }
        }
        {
      E T8, Th, Tq, Tr;
      T8 = T4 + T7;
      Th = ((KP1_961570560 * Td) - ((KP390180644) * (Tg)));
      O[(os[7])] = T8 - Th;
      O[0] = T8 + Th;
      Tq = Tk - Tl;
      Tr = (((KP1_111140466) * (Tn)) + (KP1_662939224 * To));
      O[(os[5])] = Tq - Tr;
      O[(os[2])] = Tq + Tr;
        }
        {
      E Ti, Tj, Tm, Tp;
      Ti = T4 - T7;
      Tj = (((KP390180644) * (Td)) + (KP1_961570560 * Tg));
      O[(os[4])] = Ti - Tj;
      O[(os[3])] = Ti + Tj;
      Tm = Tk + Tl;
      Tp = ((KP1_662939224 * Tn) - ((KP1_111140466) * (To)));
      O[(os[6])] = Tm - Tp;
      O[(os[1])] = Tm + Tp;
        }
   }
}

/* Test harness */

int main()
{
	INT s[8] = { 0,1,2,3,4,5,6,7 };
	static R i[1024];
	static R o[1024];
	int k;
	for (k = 0; k < 1024; ++k) i[k] = k;
	for (k = 0; k < 1024 * 1024 * 2; ++k)
		e01_8(i, o, s, s, 64, 8, 8);
        for (k = 0; k < 16; ++k)
          printf("o[%d] = %.6e\n", k, o[k]);
	return 0;
}