5
5
#include " ../util/checkpoint.hpp"
6
6
#include " ../util/big_alloc.hpp"
7
7
#include < ranges>
8
+ #include < bit>
8
9
9
10
namespace stdx = std::experimental;
10
11
namespace cp_algo ::math::fft {
@@ -67,8 +68,19 @@ namespace cp_algo::math::fft {
67
68
return polar (1 ., std::numbers::pi / (ftype)std::bit_floor (n) * (ftype)eval_arg (n));
68
69
}
69
70
}
71
+ static constexpr std::array<point, 32 > roots = []() {
72
+ std::array<point, 32 > res;
73
+ for (size_t i = 2 ; i < 32 ; i++) {
74
+ res[i] = polar (1 ., std::numbers::pi / (1ull << (i - 2 )));
75
+ }
76
+ return res;
77
+ }();
70
78
static constexpr point root (size_t n) {
71
- return eval_point (n / 2 );
79
+ return roots[std::bit_width (n)];
80
+ }
81
+ template <int step>
82
+ static void exec_on_eval (size_t n, size_t k, auto &&callback) {
83
+ callback (k, root (4 * step * n) * eval_point (step * k));
72
84
}
73
85
template <int step>
74
86
static void exec_on_evals (size_t n, auto &&callback) {
@@ -77,10 +89,6 @@ namespace cp_algo::math::fft {
77
89
callback (i, factor * eval_point (step * i));
78
90
}
79
91
}
80
- template <int step>
81
- static void exec_on_eval (size_t n, size_t k, auto &&callback) {
82
- callback (root (4 * step * n) * eval_point (step * k));
83
- }
84
92
85
93
void dot (cvector const & t) {
86
94
size_t n = this ->size ();
0 commit comments