diff options
Diffstat (limited to 'content/math')
| -rw-r--r-- | content/math/math.tex | 6 | ||||
| -rw-r--r-- | content/math/transforms/andTransform.cpp | 2 | ||||
| -rw-r--r-- | content/math/transforms/bitwiseTransforms.cpp | 4 | ||||
| -rw-r--r-- | content/math/transforms/orTransform.cpp | 2 |
4 files changed, 8 insertions, 6 deletions
diff --git a/content/math/math.tex b/content/math/math.tex index d59da54..fdf7081 100644 --- a/content/math/math.tex +++ b/content/math/math.tex @@ -321,6 +321,7 @@ sich alle Lösungen von $x^2-ny^2=c$ berechnen durch: \end{algorithm}
\begin{algorithm}{Polynome, FFT, NTT \& andere Transformationen}
+ \label{fft}
Multipliziert Polynome $A$ und $B$.
\begin{itemize}
\item $\deg(A \cdot B) = \deg(A) + \deg(B)$
@@ -328,14 +329,15 @@ sich alle Lösungen von $x^2-ny^2=c$ berechnen durch: $\deg(A \cdot B) + 1$ haben.
Größe muss eine Zweierpotenz sein.
\item Für ganzzahlige Koeffizienten: \code{(ll)round(real(a[i]))}
- \item \emph{xor}, \emph{or} und \emph{and} Transform funktioniert auch mit \code{double} oder modulo einer Primzahl $p$ falls $p \geq 2^{\texttt{bits}}$
+ \item \emph{or} Transform berechnet sum over subsets
+ $\rightarrow$ inverse für inclusion/exclusion
\end{itemize}
%\sourcecode{math/fft.cpp}
%\sourcecode{math/ntt.cpp}
\sourcecode{math/transforms/fft.cpp}
\sourcecode{math/transforms/ntt.cpp}
\sourcecode{math/transforms/bitwiseTransforms.cpp}
- Multiplikation mit 2 transforms statt 3: (nur benutzten wenn nötig!)
+ Multiplikation mit 2 Transforms statt 3: (nur benutzen wenn nötig!)
\sourcecode{math/transforms/fftMul.cpp}
\end{algorithm}
diff --git a/content/math/transforms/andTransform.cpp b/content/math/transforms/andTransform.cpp index 1e9cfc0..9e40c74 100644 --- a/content/math/transforms/andTransform.cpp +++ b/content/math/transforms/andTransform.cpp @@ -4,5 +4,5 @@ void fft(vector<ll>& a, bool inv = false) { for (int i = 0; i < n; i += 2 * s) { for (int j = i; j < i + s; j++) { ll& u = a[j], &v = a[j + s]; - tie(u, v) = inv ? pair(v - u, u) : pair(v, u + v); + tie(u, v) = inv ? pair(u - v, v) : pair(u + v, v); }}}} diff --git a/content/math/transforms/bitwiseTransforms.cpp b/content/math/transforms/bitwiseTransforms.cpp index b98ea94..17f3163 100644 --- a/content/math/transforms/bitwiseTransforms.cpp +++ b/content/math/transforms/bitwiseTransforms.cpp @@ -4,8 +4,8 @@ void bitwiseConv(vector<ll>& a, bool inv = false) { for (int i = 0; i < n; i += 2 * s) { for (int j = i; j < i + s; j++) { ll& u = a[j], &v = a[j + s]; - tie(u, v) = inv ? pair(v - u, u) : pair(v, u + v); // AND - //tie(u, v) = inv ? pair(v, u - v) : pair(u + v, u); //OR + tie(u, v) = inv ? pair(u - v, v) : pair(u + v, v); // AND + //tie(u, v) = inv ? pair(u, v - u) : pair(u, v + u); //OR //tie(u, v) = pair(u + v, u - v); // XOR }}} //if (inv) for (ll& x : a) x /= n; // XOR (careful with MOD) diff --git a/content/math/transforms/orTransform.cpp b/content/math/transforms/orTransform.cpp index d0122bf..6503a68 100644 --- a/content/math/transforms/orTransform.cpp +++ b/content/math/transforms/orTransform.cpp @@ -4,5 +4,5 @@ void fft(vector<ll>& a, bool inv = false) { for (int i = 0; i < n; i += 2 * s) { for (int j = i; j < i + s; j++) { ll& u = a[j], &v = a[j + s]; - tie(u, v) = inv ? pair(v, u - v) : pair(u + v, u); + tie(u, v) = inv ? pair(u, v - u) : pair(u, v + u); }}}} |
