aboutsummaryrefslogtreecommitdiff
path: root/aberth/polygen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'aberth/polygen.cpp')
-rw-r--r--aberth/polygen.cpp38
1 files changed, 36 insertions, 2 deletions
diff --git a/aberth/polygen.cpp b/aberth/polygen.cpp
index 6df89db..e606dc8 100644
--- a/aberth/polygen.cpp
+++ b/aberth/polygen.cpp
@@ -28,9 +28,43 @@ namespace PolyGen::Derbyshire {
return poly;
}
+ int numPolys() {
+ return 1 << N;
+ }
+}
+
+namespace PolyGen::Christensen {
+ // Returns whether we just looped around
+ bool next(Poly &poly) {
+ for (int i = 0; i < (int)poly.size(); i++) {
+ if (poly[i] < kCoeffBound) {
+ poly[i]++;
+ return false;
+ }
+ poly[i] = -kCoeffBound;
+ }
+ return true;
+ }
+
+ Poly atIndex(int index) {
+ Poly poly;
+ for (int i = 0; i < (int)poly.size(); i++) {
+ poly[i] = index % (2 * kCoeffBound + 1) - kCoeffBound;
+ index /= 2 * kCoeffBound + 1;
+ }
+ assert(index == 0);
+ return poly;
+ }
+
+ int numPolys() {
+ return ipow(2 * kCoeffBound + 1, N + 1);
+ }
+}
+
+namespace PolyGen {
vector<Job> genJobs(int targetJobs) {
- int njobs = min(1 << N, ceil2(targetJobs));
- int jobsize = (1 << N) / njobs;
+ int njobs = min(numPolys(), ceil2(targetJobs));
+ int jobsize = numPolys() / njobs;
vector<Job> jobs(njobs);
for (int i = 0; i < njobs; i++) {