Skip to content

Commit 094e5d5

Browse files
committed
Split into finer subsections
1 parent 120f099 commit 094e5d5

File tree

8 files changed

+55
-54
lines changed

8 files changed

+55
-54
lines changed

content/numerical/PolyIntegDeriv.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Author: chilli, Andrew He, Adamant
3+
* Date: 2019-04-27
4+
* Description: A FFT based Polynomial class.
5+
*/
6+
#pragma once
7+
#include "PolyBase.h"
8+
9+
poly deriv(poly a) {
10+
if (a.empty()) return {};
11+
poly b(sz(a) - 1);
12+
rep(i, 1, sz(a)) b[i - 1] = a[i] * num(i);
13+
return b;
14+
}
15+
poly integr(poly a) {
16+
if (a.empty()) return {0};
17+
poly b(sz(a) + 1);
18+
b[1] = num(1);
19+
rep(i, 2, sz(b)) b[i] = b[mod%i]*Mod(-mod/i+mod);
20+
rep(i, 1 ,sz(b)) b[i] = a[i-1] * b[i];
21+
return b;
22+
}

content/numerical/PolyInterpolate.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/**
22
* Author: chilli, Andrew He, Adamant
33
* Date: 2019-04-27
4-
* Description: A FFT based Polynomial class.
4+
* Description: Given $n$ points (x[i], y[i]), computes an n-1-degree polynomial $p$ that
5+
* passes through them: $p(x) = a[0]*x^0 + ... + a[n-1]*x^{n-1}$.
6+
* Time: O(n \log^2 n)
57
*/
68
#pragma once
79

content/numerical/PolyLogExp.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Author: chilli, Andrew He, Adamant
3+
* Date: 2019-04-27
4+
* Description: A FFT based Polynomial class.
5+
*/
6+
#pragma once
7+
8+
#include "PolyBase.h"
9+
#include "PolyIntegDeriv.h"
10+
11+
poly log(poly a) {
12+
return modK(integr(deriv(a) * inverse(a)), sz(a));
13+
}
14+
poly exp(poly a) {
15+
poly b(1, num(1));
16+
if (a.empty())
17+
return b;
18+
while (sz(b) < sz(a)) {
19+
b.resize(sz(b) * 2);
20+
b *= (poly({num(1)}) + modK(a, sz(b)) - log(b));
21+
b.resize(sz(b) / 2 + 1);
22+
}
23+
return modK(b, sz(a));
24+
}

content/numerical/PolyPow.h

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,8 @@
66
#pragma once
77

88
#include "PolyBase.h"
9-
poly deriv(poly a) {
10-
if (a.empty())
11-
return {};
12-
poly b(sz(a) - 1);
13-
rep(i, 1, sz(a)) b[i - 1] = a[i] * num(i);
14-
return b;
15-
}
16-
poly integr(poly a) {
17-
if (a.empty()) return {0};
18-
poly b(sz(a) + 1);
19-
b[1] = num(1);
20-
rep(i, 2, sz(b)) b[i] = b[mod%i]*Mod(-mod/i+mod);
21-
rep(i, 1 ,sz(b)) b[i] = a[i-1] * b[i];
22-
return b;
23-
}
24-
poly log(poly a) {
25-
return modK(integr(deriv(a) * inverse(a)), sz(a));
26-
}
27-
poly exp(poly a) {
28-
poly b(1, num(1));
29-
if (a.empty())
30-
return b;
31-
while (sz(b) < sz(a)) {
32-
b.resize(sz(b) * 2);
33-
b *= (poly({num(1)}) + modK(a, sz(b)) - log(b));
34-
b.resize(sz(b) / 2 + 1);
35-
}
36-
return modK(b, sz(a));
37-
}
9+
#include "PolyLogExp.h"
10+
3811
poly pow(poly a, ll m) {
3912
int p = 0, n = sz(a);
4013
while (p < sz(a) && a[p].x == 0)

content/numerical/Polynomial.h

Lines changed: 0 additions & 24 deletions
This file was deleted.

content/numerical/chapter.tex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ \chapter{Numerical}
33
\kactlimport{GoldenSectionSearch.h}
44
\kactlimport{PolyBase.h}
55
\kactlimport{PolyMod.h}
6+
\kactlimport{PolyIntegDeriv.h}
7+
\kactlimport{PolyLogExp.h}
68
\kactlimport{PolyPow.h}
79
\kactlimport{PolyInterpolate.h}
810
\kactlimport{PolyEvaluate.h}

fuzz-tests/numerical/Polynomial.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,8 @@ typedef vector<num> poly;
420420

421421
#include "../../content/numerical/PolyBase.h"
422422
#include "../../content/numerical/PolyMod.h"
423+
#include "../../content/numerical/PolyIntegDeriv.h"
424+
#include "../../content/numerical/PolyLogExp.h"
423425
#include "../../content/numerical/PolyPow.h"
424426
#include "../../content/numerical/PolyEvaluate.h"
425427
#include "../../content/numerical/PolyInterpolate.h"

kactl.pdf

2.22 MB
Binary file not shown.

0 commit comments

Comments
 (0)