55#include " ../util/checkpoint.hpp"
66#include " ../util/big_alloc.hpp"
77#include < ranges>
8+ #include < bit>
89
910namespace stdx = std::experimental;
1011namespace cp_algo ::math::fft {
@@ -67,8 +68,19 @@ namespace cp_algo::math::fft {
6768 return polar (1 ., std::numbers::pi / (ftype)std::bit_floor (n) * (ftype)eval_arg (n));
6869 }
6970 }
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+ }();
7078 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));
7284 }
7385 template <int step>
7486 static void exec_on_evals (size_t n, auto &&callback) {
@@ -77,10 +89,6 @@ namespace cp_algo::math::fft {
7789 callback (i, factor * eval_point (step * i));
7890 }
7991 }
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- }
8492
8593 void dot (cvector const & t) {
8694 size_t n = this ->size ();
0 commit comments