fft_impl4.c
1.35 KB
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
//
// fft_impl4.c: this file is part of the SL program suite.
//
// Copyright (C) 2009 The SL project.
// Copyright (C) 2020 daiteq.
//
//
enum { MAX_M = TABLE_SIZE, MAX_N = 1 << MAX_M };
static const cpx_t sc_table[ MAX_N ] = {
#define HEADERNAME MAKENAME(2, TABLE_SIZE)
#define HEADER STRINGIFY(HEADERNAME)
#include HEADER
};
const void* sc_table_ptr = sc_table;
void FFT_2(unsigned p, unsigned long LE2, const cpx_t* restrict cos_sin, cpx_t* restrict X, unsigned long Z)
{
unsigned i = p;
const unsigned long w = i & ((LE2) - 1);
const unsigned long j = (i - w) * 2 + w;
const unsigned long ip = j + (LE2);
cpx_t* restrict x = (X);
const cpx_t U = (cos_sin)[w * (Z)];
cpx_t T; // const cpx_t
dcmul(U,x[ip], T);
const cpx_t xj = x[j];
dcsub(xj, T, x[ip]);
dcadd(xj, T, x[j]);
}
void FFT_1_mt(unsigned p, cpx_t* restrict X, unsigned long N2, const void* t)
{
int i;
unsigned k = p+1;
const cpx_t*restrict cos_sin = (const cpx_t*restrict)(const void*)(t);
unsigned long Z = (MAX_N >> k);
unsigned long LE = (1 << k);
for (i=0;i<N2;i++)
FFT_2(i, LE/2, cos_sin, X, Z);
}
static
void FFT_1(unsigned long M, cpx_t*restrict X, unsigned long N2, const void* t, unsigned blocksize)
{
int i;
for (i=0;i<M;i++) {
// printf("M %lu,i %u\n",M,i);
FFT_1_mt(i, X, N2, t);
}
}