Loading docs/math/poly/fft.md +101 −101 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ NTT 部分代码参考 CSDN 上的模板代码附网址,感谢博主! > 离散傅里叶变换(Discrete Fourier Transform,缩写为 DFT),是傅里叶变换在时域和频域上都呈离散的形式,将信号的时域采样变换为其 DTFT 的频域采样。 > > FFT 是一种 DFT 的高效算法,称为快速傅立叶变换(fast Fourier transform)。——百度百科 > FFT 是一种 DFT 的高效算法,称为快速傅立叶变换(Fast Fourier transform)。——百度百科 在百度百科上能找到 DFT 和 FFT 这两个定义。正如定义,FFT 和 DFT 实际上按照结果来看的话是一样的,但是 FFT 比较快的计算 DFT 和 IDFT(离散反傅里叶变换)。 Loading Loading @@ -405,14 +405,14 @@ void fft(Complex y[], int len, int on) { 好了现在附上全部代码([HDU 1402](http://acm.hdu.edu.cn/showproblem.php?pid=1402)),序言说过代码来自 kuangbin 的模板~~~~~ ??? " FFT " ```cpp #include <cmath> #include <cstdio> #include <cstring> #include <iostream> using namespace std; const double PI = acos(-1.0); struct Complex { double x, y; Loading docs/math/poly/intro.md +25 −23 Original line number Diff line number Diff line ## 前置知识 FFT,多项式乘法 ## Basic Concepts ### 多项式的度 对于一个多项式 $f\left(x\right)$,称其最高次项的次数为该多项式的**度(Degree)**,记作 $\operatorname{deg}{f}$。 对于一个多项式 $f(x)$,称其最高次项的次数为该多项式的**度(Degree)**,记作 $\operatorname{deg}{f}$。 ### 多项式的逆元 对于多项式 $f\left(x\right)$,若存在 $g\left(x\right)$ 满足: 对于多项式 $f(x)$,若存在 $g(x)$ 满足: $$ \begin{aligned} f\left(x\right)g\left(x\right)&\equiv 1\pmod{x^{n}}\\ \operatorname{deg}{g}&\leqslant\operatorname{deg}{f} f(x) g(x) & \equiv 1 \pmod{x^{n}} \\ \operatorname{deg}{g} & \le \operatorname{deg}{f} \end{aligned} $$ 则称 $g\left(x\right)$ 为 $f\left(x\right)$ 在模 $x^{n}$ 意义下的**逆元(Inverse Element)**,记作 $f^{-1}\left(x\right)$。 则称 $g(x)$ 为 $f(x)$ 在模 $x^{n}$ 意义下的**逆元(Inverse Element)**,记作 $f^{-1}(x)$。 ### 多项式的余数和商 对于多项式 $f\left(x\right),g\left(x\right)$,存在**唯一**的 $Q\left(x\right),R\left(x\right)$ 满足: 对于多项式 $f(x), g(x)$,存在**唯一**的 $Q(x), R(x)$ 满足: $$ \begin{aligned} f\left(x\right)&=Q\left(x\right)g\left(x\right)+R\left(x\right)\\ f(x) &= Q(x) g(x) + R(x) \\ \operatorname{deg}{Q} &= \operatorname{deg}{f} - \operatorname{deg}{g} \\ \operatorname{deg}{R} &< \operatorname{deg}{g} \end{aligned} $$ 我们称 $Q\left(x\right)$ 为 $g\left(x\right)$ 除 $f\left(x\right)$ 的**商(Quotient)**,$R\left(x\right)$ 为 $g\left(x\right)$ 除 $f\left(x\right)$ 的**余数(Remainder)**. 我们称 $Q(x)$ 为 $g(x)$ 除 $f(x)$ 的**商(Quotient)**,R(x)$ 为 $g(x)$ 除 $f(x)$ 的**余数(Remainder)**。 亦可记作 $$f\left(x\right)\equiv R\left(x\right)\pmod{g\left(x\right)}$$ $$ f(x) \equiv R(x) \pmod{g(x)} $$ ### <span id="ln-exp">多项式的对数函数与指数函数</span> 对于一个多项式 $f\left(x\right)$,可以将其对数函数看作其与麦克劳林级数的复合: 对于一个多项式 $f(x)$,可以将其对数函数看作其与麦克劳林级数的复合: $$\ln{\left(1-f\left(x\right)\right)}=-\sum_{i=1}^{+\infty}\frac{f^{i}\left(x\right)}{i}$$ $$ \ln{(1 - f(x))} = -\sum_{i = 1}^{+\infty} \frac{f^{i}(x)}{i} = \sum_{i = 1}^{+\infty} \frac{(-1)^{i - 1}f^{i}(x)}{i} $$ 其指数函数同样可以这样定义: $$\exp{f\left(x\right)}=e^{f\left(x\right)}=\sum_{i=0}^{+\infty}\frac{f^{i}\left(x\right)}{i!}$$ $$ \exp{f(x)} = e^{f(x)} = \sum_{i = 0}^{+\infty} \frac{f^{i}(x)}{i!} $$ ### 多项式的多点求值和插值 **多项式的多点求值(Multi-point evaluation)** 即给出一个多项式 $f\left(x\right)$ 和 $n$ 个点 $x_{1},x_{2},...,x_{n}$,求 **多项式的多点求值(Multi-point evaluation)** 即给出一个多项式 $f(x)$ 和 $n$ 个点 $x_{1}, x_{2}, \dots, x_{n}$,求 $$f\left(x_{1}\right),f\left(x_{2}\right),...,f\left(x_{n}\right) $$ $$ f(x_{1}), f(x_{2}), \dots, f(x_{n}) $$ **多项式的插值(Interpolation)** 即给出 $n+1$ 个点 **多项式的插值(Interpolation)** 即给出 $n + 1$ 个点 $$\left(x_{0},y_{0}\right),\left(x_{1},y_{1}\right),...,\left(x_{n},y_{n}\right) $$ $$(x_{0}, y_{0}), (x_{1}, y_{1}), \dots, (x_{n}, y_{n}) $$ 求一个 $n$ 次多项式 $f\left(x\right)$ 使得这 $n+1$ 个点都在 $f\left(x\right)$ 上. 求一个 $n$ 次多项式 $f(x)$ 使得这 $n + 1$ 个点都在 $f(x)$ 上。 这两种操作的实质就是将多项式在**系数表示**和**点值表示**间转化。 ## References [**Picks's Blog**](https://picks.logdown.com) [**Miskcoo's Space**](https://blog.miskcoo.com) - [**Picks's Blog**](https://picks.logdown.com) - [**Miskcoo's Space**](https://blog.miskcoo.com) Loading
docs/math/poly/fft.md +101 −101 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ NTT 部分代码参考 CSDN 上的模板代码附网址,感谢博主! > 离散傅里叶变换(Discrete Fourier Transform,缩写为 DFT),是傅里叶变换在时域和频域上都呈离散的形式,将信号的时域采样变换为其 DTFT 的频域采样。 > > FFT 是一种 DFT 的高效算法,称为快速傅立叶变换(fast Fourier transform)。——百度百科 > FFT 是一种 DFT 的高效算法,称为快速傅立叶变换(Fast Fourier transform)。——百度百科 在百度百科上能找到 DFT 和 FFT 这两个定义。正如定义,FFT 和 DFT 实际上按照结果来看的话是一样的,但是 FFT 比较快的计算 DFT 和 IDFT(离散反傅里叶变换)。 Loading Loading @@ -405,14 +405,14 @@ void fft(Complex y[], int len, int on) { 好了现在附上全部代码([HDU 1402](http://acm.hdu.edu.cn/showproblem.php?pid=1402)),序言说过代码来自 kuangbin 的模板~~~~~ ??? " FFT " ```cpp #include <cmath> #include <cstdio> #include <cstring> #include <iostream> using namespace std; const double PI = acos(-1.0); struct Complex { double x, y; Loading
docs/math/poly/intro.md +25 −23 Original line number Diff line number Diff line ## 前置知识 FFT,多项式乘法 ## Basic Concepts ### 多项式的度 对于一个多项式 $f\left(x\right)$,称其最高次项的次数为该多项式的**度(Degree)**,记作 $\operatorname{deg}{f}$。 对于一个多项式 $f(x)$,称其最高次项的次数为该多项式的**度(Degree)**,记作 $\operatorname{deg}{f}$。 ### 多项式的逆元 对于多项式 $f\left(x\right)$,若存在 $g\left(x\right)$ 满足: 对于多项式 $f(x)$,若存在 $g(x)$ 满足: $$ \begin{aligned} f\left(x\right)g\left(x\right)&\equiv 1\pmod{x^{n}}\\ \operatorname{deg}{g}&\leqslant\operatorname{deg}{f} f(x) g(x) & \equiv 1 \pmod{x^{n}} \\ \operatorname{deg}{g} & \le \operatorname{deg}{f} \end{aligned} $$ 则称 $g\left(x\right)$ 为 $f\left(x\right)$ 在模 $x^{n}$ 意义下的**逆元(Inverse Element)**,记作 $f^{-1}\left(x\right)$。 则称 $g(x)$ 为 $f(x)$ 在模 $x^{n}$ 意义下的**逆元(Inverse Element)**,记作 $f^{-1}(x)$。 ### 多项式的余数和商 对于多项式 $f\left(x\right),g\left(x\right)$,存在**唯一**的 $Q\left(x\right),R\left(x\right)$ 满足: 对于多项式 $f(x), g(x)$,存在**唯一**的 $Q(x), R(x)$ 满足: $$ \begin{aligned} f\left(x\right)&=Q\left(x\right)g\left(x\right)+R\left(x\right)\\ f(x) &= Q(x) g(x) + R(x) \\ \operatorname{deg}{Q} &= \operatorname{deg}{f} - \operatorname{deg}{g} \\ \operatorname{deg}{R} &< \operatorname{deg}{g} \end{aligned} $$ 我们称 $Q\left(x\right)$ 为 $g\left(x\right)$ 除 $f\left(x\right)$ 的**商(Quotient)**,$R\left(x\right)$ 为 $g\left(x\right)$ 除 $f\left(x\right)$ 的**余数(Remainder)**. 我们称 $Q(x)$ 为 $g(x)$ 除 $f(x)$ 的**商(Quotient)**,R(x)$ 为 $g(x)$ 除 $f(x)$ 的**余数(Remainder)**。 亦可记作 $$f\left(x\right)\equiv R\left(x\right)\pmod{g\left(x\right)}$$ $$ f(x) \equiv R(x) \pmod{g(x)} $$ ### <span id="ln-exp">多项式的对数函数与指数函数</span> 对于一个多项式 $f\left(x\right)$,可以将其对数函数看作其与麦克劳林级数的复合: 对于一个多项式 $f(x)$,可以将其对数函数看作其与麦克劳林级数的复合: $$\ln{\left(1-f\left(x\right)\right)}=-\sum_{i=1}^{+\infty}\frac{f^{i}\left(x\right)}{i}$$ $$ \ln{(1 - f(x))} = -\sum_{i = 1}^{+\infty} \frac{f^{i}(x)}{i} = \sum_{i = 1}^{+\infty} \frac{(-1)^{i - 1}f^{i}(x)}{i} $$ 其指数函数同样可以这样定义: $$\exp{f\left(x\right)}=e^{f\left(x\right)}=\sum_{i=0}^{+\infty}\frac{f^{i}\left(x\right)}{i!}$$ $$ \exp{f(x)} = e^{f(x)} = \sum_{i = 0}^{+\infty} \frac{f^{i}(x)}{i!} $$ ### 多项式的多点求值和插值 **多项式的多点求值(Multi-point evaluation)** 即给出一个多项式 $f\left(x\right)$ 和 $n$ 个点 $x_{1},x_{2},...,x_{n}$,求 **多项式的多点求值(Multi-point evaluation)** 即给出一个多项式 $f(x)$ 和 $n$ 个点 $x_{1}, x_{2}, \dots, x_{n}$,求 $$f\left(x_{1}\right),f\left(x_{2}\right),...,f\left(x_{n}\right) $$ $$ f(x_{1}), f(x_{2}), \dots, f(x_{n}) $$ **多项式的插值(Interpolation)** 即给出 $n+1$ 个点 **多项式的插值(Interpolation)** 即给出 $n + 1$ 个点 $$\left(x_{0},y_{0}\right),\left(x_{1},y_{1}\right),...,\left(x_{n},y_{n}\right) $$ $$(x_{0}, y_{0}), (x_{1}, y_{1}), \dots, (x_{n}, y_{n}) $$ 求一个 $n$ 次多项式 $f\left(x\right)$ 使得这 $n+1$ 个点都在 $f\left(x\right)$ 上. 求一个 $n$ 次多项式 $f(x)$ 使得这 $n + 1$ 个点都在 $f(x)$ 上。 这两种操作的实质就是将多项式在**系数表示**和**点值表示**间转化。 ## References [**Picks's Blog**](https://picks.logdown.com) [**Miskcoo's Space**](https://blog.miskcoo.com) - [**Picks's Blog**](https://picks.logdown.com) - [**Miskcoo's Space**](https://blog.miskcoo.com)