src/conv/trans/fft_r2/lib.hpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include "../../../util/alias/others/lib.hpp" | ||
| 4 | |||
| 5 | namespace tifa_libs { | ||
| 6 | |||
| 7 | template <std::floating_point FP> | ||
| 8 | class fft_r2 { | ||
| 9 | using C = std::complex<FP>; | ||
| 10 | const FP TAU = std::acos((FP)-1.) * 2; | ||
| 11 | vecu rev; | ||
| 12 | vec<C> w; | ||
| 13 | |||
| 14 | public: | ||
| 15 | using data_t = C; | ||
| 16 | |||
| 17 | 32850780 | ND CEXP u32 size() CNE { return (u32)rev.size(); } | |
| 18 | 3285078 | CEXP void bzr(u32 len) NE { | |
| 19 | 3285078 | cu32 n = max(std::bit_ceil(len), 2_u32); | |
| 20 |
3/4tifa_libs::fft_r2<double>::bzr(unsigned int):
✓ Branch 1 taken 1315506 times.
✓ Branch 2 taken 1969182 times.
tifa_libs::fft_r2<long double>::bzr(unsigned int):
✗ Branch 1 not taken.
✓ Branch 2 taken 390 times.
|
3285078 | if (n == size()) return; |
| 21 | 1969572 | rev.resize(n, 0); | |
| 22 | 1969572 | cu32 k = (u32)(std::bit_width(n) - 1); | |
| 23 |
4/4tifa_libs::fft_r2<double>::bzr(unsigned int):
✓ Branch 2 taken 5161739520 times.
✓ Branch 3 taken 1969182 times.
tifa_libs::fft_r2<long double>::bzr(unsigned int):
✓ Branch 2 taken 296450304 times.
✓ Branch 3 taken 390 times.
|
5460159396 | flt_ (u32, i, 0, n) rev[i] = (rev[i / 2] / 2) | ((i & 1) << (k - 1)); |
| 24 | 1969572 | w.resize(n), w[0].real(1); | |
| 25 |
4/4tifa_libs::fft_r2<double>::bzr(unsigned int):
✓ Branch 2 taken 5159770338 times.
✓ Branch 3 taken 1969182 times.
tifa_libs::fft_r2<long double>::bzr(unsigned int):
✓ Branch 4 taken 296449914 times.
✓ Branch 5 taken 390 times.
|
5458189824 | flt_ (u32, i, 1, n) w[i] = {std::cos(TAU * (FP)i / (FP)n), std::sin(TAU * (FP)i / (FP)n)}; |
| 26 | } | ||
| 27 | 13140312 | CEXP void dif(vec<data_t>& f, u32 n = 0) CNE { | |
| 28 |
2/4tifa_libs::fft_r2<double>::dif(std::vector<std::complex<double>, std::allocator<std::complex<double> > >&, unsigned int) const:
✓ Branch 0 taken 13138752 times.
✗ Branch 1 not taken.
tifa_libs::fft_r2<long double>::dif(std::vector<std::complex<long double>, std::allocator<std::complex<long double> > >&, unsigned int) const:
✓ Branch 0 taken 1560 times.
✗ Branch 1 not taken.
|
13140312 | if (!n) n = size(); |
| 29 |
2/4tifa_libs::fft_r2<double>::dif(std::vector<std::complex<double>, std::allocator<std::complex<double> > >&, unsigned int) const:
✗ Branch 1 not taken.
✓ Branch 2 taken 13138752 times.
tifa_libs::fft_r2<long double>::dif(std::vector<std::complex<long double>, std::allocator<std::complex<long double> > >&, unsigned int) const:
✗ Branch 1 not taken.
✓ Branch 2 taken 1560 times.
|
13140312 | if (f.size() < n) f.resize(n); |
| 30 |
2/4tifa_libs::fft_r2<double>::dif(std::vector<std::complex<double>, std::allocator<std::complex<double> > >&, unsigned int) const:
✗ Branch 1 not taken.
✓ Branch 2 taken 13138752 times.
tifa_libs::fft_r2<long double>::dif(std::vector<std::complex<long double>, std::allocator<std::complex<long double> > >&, unsigned int) const:
✗ Branch 1 not taken.
✓ Branch 2 taken 1560 times.
|
13140312 | assert(n <= size()); |
| 31 |
4/4tifa_libs::fft_r2<double>::dif(std::vector<std::complex<double>, std::allocator<std::complex<double> > >&, unsigned int) const:
✓ Branch 0 taken 24171023616 times.
✓ Branch 1 taken 13138752 times.
tifa_libs::fft_r2<long double>::dif(std::vector<std::complex<long double>, std::allocator<std::complex<long double> > >&, unsigned int) const:
✓ Branch 0 taken 1185801216 times.
✓ Branch 1 taken 1560 times.
|
25369965144 | flt_ (u32, i, 0, n) |
| 32 |
4/4tifa_libs::fft_r2<double>::dif(std::vector<std::complex<double>, std::allocator<std::complex<double> > >&, unsigned int) const:
✓ Branch 1 taken 11960477760 times.
✓ Branch 2 taken 12210545856 times.
tifa_libs::fft_r2<long double>::dif(std::vector<std::complex<long double>, std::allocator<std::complex<long double> > >&, unsigned int) const:
✓ Branch 1 taken 592294080 times.
✓ Branch 2 taken 593507136 times.
|
25356824832 | if (i < rev[i]) swap(f[rev[i]], f[i]); |
| 33 | #pragma GCC diagnostic ignored "-Wsign-conversion" | ||
| 34 |
4/4tifa_libs::fft_r2<double>::dif(std::vector<std::complex<double>, std::allocator<std::complex<double> > >&, unsigned int) const:
✓ Branch 0 taken 92687496 times.
✓ Branch 1 taken 13138752 times.
tifa_libs::fft_r2<long double>::dif(std::vector<std::complex<long double>, std::allocator<std::complex<long double> > >&, unsigned int) const:
✓ Branch 0 taken 27576 times.
✓ Branch 1 taken 1560 times.
|
105855384 | for (u32 i = 2, d = n / 2; i <= n; i *= 2, d /= 2) |
| 35 |
4/4tifa_libs::fft_r2<double>::dif(std::vector<std::complex<double>, std::allocator<std::complex<double> > >&, unsigned int) const:
✓ Branch 0 taken 24157884864 times.
✓ Branch 1 taken 92687496 times.
tifa_libs::fft_r2<long double>::dif(std::vector<std::complex<long double>, std::allocator<std::complex<long double> > >&, unsigned int) const:
✓ Branch 0 taken 1185799656 times.
✓ Branch 1 taken 27576 times.
|
25436399592 | for (u32 j = 0; j < n; j += i) { |
| 36 | 25343684520 | auto l = begin(f) + j, r = begin(f) + j + i / 2; | |
| 37 | 25343684520 | auto p = begin(w); | |
| 38 |
4/4tifa_libs::fft_r2<double>::dif(std::vector<std::complex<double>, std::allocator<std::complex<double> > >&, unsigned int) const:
✓ Branch 2 taken 209119320960 times.
✓ Branch 3 taken 24157884864 times.
tifa_libs::fft_r2<long double>::dif(std::vector<std::complex<long double>, std::allocator<std::complex<long double> > >&, unsigned int) const:
✓ Branch 2 taken 11835807744 times.
✓ Branch 3 taken 1185799656 times.
|
246298813224 | for (u32 k = 0; k < i / 2; ++k, ++l, ++r, p += d) { |
| 39 | 220955128704 | const data_t _ = *r * *p; | |
| 40 | 220955128704 | *r = *l - _, *l = *l + _; | |
| 41 | } | ||
| 42 | } | ||
| 43 | #pragma GCC diagnostic warning "-Wsign-conversion" | ||
| 44 | 13140312 | } | |
| 45 | CEXP void dit(vec<data_t>& f, u32 n = 0) CNE { | ||
| 46 | if (!n) n = size(); | ||
| 47 | dif(f, n); | ||
| 48 | flt_ (u32, i, 0, n) f[i] /= (FP)n; | ||
| 49 | } | ||
| 50 | }; | ||
| 51 | |||
| 52 | } // namespace tifa_libs | ||
| 53 |