blob: 2973deb4403ff20d6b73f1a3d35849cbb8c99e88 (
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
|
typedef struct
{
double re;
double im;
} complex_t;
static inline complex_t
complex_mul (complex_t a, complex_t b)
{
complex_t r;
r.re = a.re * b.re - a.im * b.im;
r.im = a.re * b.im + a.im * b.re;
return r;
}
static inline complex_t
complex_add (complex_t a, complex_t b)
{
complex_t r;
r.re = a.re + b.re;
r.im = a.im + b.im;
return r;
}
static inline complex_t
complex_sub (complex_t a, complex_t b)
{
complex_t r;
r.re = a.re - b.re;
r.im = a.im - b.im;
return r;
}
static inline double
complex_mag (complex_t a)
{
return sqrt (a.re * a.re + a.im * a.im);
}
static inline double
complex_arg (complex_t a)
{
return atan2 (a.im, a.re) + M_PI;
}
static inline double
rad_to_degree (double theta)
{
return theta * (360.0 / (2 * M_PI));
}
void
fft (complex_t *buffer, int n);
|