Skip to content

Commit 59dc45c

Browse files
authored
reduce the size of the FFT coefficient table (#73)
1 parent 5ef6645 commit 59dc45c

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.10)
2-
project(dsplib LANGUAGES CXX VERSION 0.54.4)
2+
project(dsplib LANGUAGES CXX VERSION 0.54.5)
33

44
set(CMAKE_CXX_STANDARD 17)
55
set(CMAKE_CXX_STANDARD_REQUIRED ON)

lib/fft/pow2-fft.cpp

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,19 @@ std::vector<cmplx_t> _gen_coeffs_table(int n) noexcept {
3535
DSPLIB_ASSUME(n % 4 == 0);
3636
const int n4 = n / 4;
3737
const int n2 = n / 2;
38-
const int n3 = 3 * n / 4;
39-
std::vector<cmplx_t> res(n);
40-
res[0] = {1, 0};
41-
res[n4] = {0, -1};
42-
res[n2] = {-1, 0};
43-
res[n3] = {0, 1};
44-
//use only first n/4 samples
38+
std::vector<cmplx_t> tb(n / 2);
39+
40+
//calculate only first n/4 samples
41+
tb[0] = {1, 0};
42+
tb[n4] = {0, -1};
4543
for (int i = 1; i < n4; ++i) {
4644
const auto v = std::cos(2 * pi * i / n);
47-
res[i].re = v;
48-
res[n - i].re = v;
49-
res[n2 + i].re = -v;
50-
res[n2 - i].re = -v;
51-
res[n4 + i].im = -v;
52-
res[n4 - i].im = -v;
53-
res[n3 + i].im = v;
54-
res[n3 - i].im = v;
45+
tb[i].re = v;
46+
tb[n2 - i].re = -v;
47+
tb[n4 + i].im = -v;
48+
tb[n4 - i].im = -v;
5549
}
56-
return res;
50+
return tb;
5751
}
5852

5953
//bit reverse array permutation
@@ -93,7 +87,6 @@ int Pow2FftPlan::size() const noexcept {
9387
return n_;
9488
}
9589

96-
//TODO: add "small" implementations (2, 4, 8)
9790
void Pow2FftPlan::_fft(const cmplx_t* restrict in, cmplx_t* restrict out, int n) const noexcept {
9891
DSPLIB_ASSUME(n % 2 == 0);
9992
DSPLIB_ASSUME(n >= 2);

0 commit comments

Comments
 (0)