aboutsummaryrefslogtreecommitdiff
path: root/aberth/poly.cpp
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2019-04-20 21:15:46 +0200
committertomsmeding <tom.smeding@gmail.com>2019-04-20 21:16:10 +0200
commit284ce56948aae60134a1073c6499c7fb97ffb326 (patch)
tree174a34d94072f4ee819a89101ef6ff182e5bcf4b /aberth/poly.cpp
parentccade8e6ed96fb48b329d22aaa4c8d0826b3c8d1 (diff)
More reorganisation
Diffstat (limited to 'aberth/poly.cpp')
-rw-r--r--aberth/poly.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/aberth/poly.cpp b/aberth/poly.cpp
new file mode 100644
index 0000000..cf19816
--- /dev/null
+++ b/aberth/poly.cpp
@@ -0,0 +1,28 @@
+#include <sstream>
+#include "poly.h"
+
+
+ostream& operator<<(ostream &os, const Poly &p) {
+ static const char *supers[10] = {
+ "⁰", "¹", "²", "³", "⁴", "⁵", "⁶", "⁷", "⁸", "⁹"
+ };
+
+ os << p[0];
+
+ for (int i = 1; i < (int)p.size(); i++) {
+ if (p[i] < 0) os << " - " << -p[i];
+ else if (p[i] > 0) os << " + " << p[i];
+ else continue;
+
+ os << "x";
+
+ if (i == 1) continue;
+
+ ostringstream ss;
+ ss << i;
+ string s = ss.str();
+ for (char c : s) os << supers[c - '0'];
+ }
+
+ return os;
+}