-
Notifications
You must be signed in to change notification settings - Fork 0
/
fft_complete_impl.hpp
50 lines (44 loc) · 1010 Bytes
/
fft_complete_impl.hpp
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
// SPDX-License-Identifier: GPL-2.0
#include "aligned_buf.hpp"
template <typename T>
static T my_conj(T);
template <>
std::complex<double>
inline my_conj<std::complex<double>> (std::complex<double> d)
{
return std::conj(d);
}
template <>
double
inline my_conj<double> (double d)
{
return d;
}
template <typename T1, typename T2, typename FUNC>
static inline void fft_complete(size_t N, T1 * __restrict__ in, T2 * __restrict__ data, FUNC fn)
{
in = assume_aligned(in);
data = assume_aligned(data);
T2 *out = data;
T2 *out2 = data + N;
*out++ = fn(std::conj(*in++));
for (size_t x = 0; x < N / 2 - 1; ++x) {
T2 d = fn(*in++);
*out++ = my_conj(d);
*--out2 = d;
}
*out++ = fn(std::conj(*in++));
out += N / 2 - 1;
out2 = data + N*N;
for (size_t y = 0; y < N - 1; ++y) {
*out++ = fn(std::conj(*in++));
for (size_t x = 0; x < N / 2 - 1; ++x) {
T2 d = fn(*in++);
*out++ = my_conj(d);
*--out2 = d;
}
*out++ = fn(std::conj(*in++));
out += N / 2 - 1;
out2 -= N / 2 + 1;
}
}