# 快速傅里叶变换算法

$$c_r = \sum_{i,j}[(i+j)\ mod \ n = r]a_ib_j$$

$$[(i+j) \ mod \ n = r] \\= [(i+j-r) \ mod \ n = 0] \\= \frac{1}{n} \sum_{k=0}^{n-1}{w^{(i+j-r)k}} \\= \frac{1}{n} \sum_{k=0}^{n-1}{w^{ik}w^{jk}w^{-rk}}$$

$$A(x) = \sum_{k}{x^ka_k}$$
$O(x),E(x)$为$A(x)$ 奇项偶项之和

$$A(w_{n}^m) = E((w_n^m)^2) + w_n^mO((w_n^m)^2) \\= E(w_{n/2}^m) + w_n^m O(w_{n/2}^m)$$
$$A(w_{n}^{m+n/2}) = E((w_n^m)^2) + w_n^{m+n/2}O((w_n^m)^2) \\= E(w_{n/2}^m) - w_n^m O(w_{n/2}^m)$$

$$T(n) = 2T(n/2)+O(n)$$ $$T(n) = O(nlogn)$$

$$A(x) = A_1(x)M + A_2(x)$$
$$B(x) = B_1(x)M + B_2(x)$$
$$A \times B= A_1 \times B_1 \cdot M^2 + (A_1 \times B_2 + A_2 \times B_1)M + A_2 \times B_2$$

，这样参照long double精度，实现了将 $10^6$ 阶的多项式在取余任意小于等于INT_MAX的任意模数下

$$P(x) = A(x) + B(x)i$$
$$Q(x) = A(x) - B(x)i$$

$$p_r = \sum_{k}{w_n^{kr}(A_k + B_ki)} \\=\sum_{k}{(A_k+B_ki)[cos(\pi/d) + sin(\pi/d)i]} \\= A cosw+Asinwi+Bcoswi-Bsinw \\= conj[Acos(-w)+Asin(-w)i+Bcos(-w)i-Bsin(-w)] \\= conj[\sum_{k}{(A_k-B_ki)(cos(\pi/d)+sin(\pi/d))}] \\= conj[q_{n-r}]$$
$$a_r = \frac{p_r+conj[p_{n-r}]}{2}$$$$b_r = \frac{p_r-conj[p_{n-r}]}{2}$$

$$(a\cdot b\% m)\% 2^{64} \\ = (a\cdot b - \lfloor\frac{a\cdot b}{m}\rfloor\cdot m) \% 2^{64} \ \\ = ((a\cdot b)\%2^{64} - (\lfloor\frac{a\cdot b}{m}\rfloor\cdot m)\%2^{64}) \% 2^{64}$$

posted @ 2018-07-15 23:09  lawyer'  阅读(242)  评论(0编辑  收藏  举报