#include // test for ring template void test_ring (int p) { R zero (0); R one (1); R minus_one (-1); assert (zero == 0); assert (zero | zero); assert (one | zero); assert (minus_one | zero); assert (! (zero | one)); assert (! (zero | minus_one)); assert (one.is_unit ()); assert (minus_one.is_unit ()); assert (one.recip () == one); assert (minus_one.recip () == minus_one); if (p) assert (R (p) == 0); if (p != 2) assert (one != minus_one); int n = (p ? std::min (p, 20) : 20); for (int i = -n; i <= n; i ++) { R x (i); if (x.is_unit ()) { assert (x * x.recip () == one); assert (x.recip () * x == one); assert (x.recip ().recip () == x); } assert (one | x); assert (minus_one | x); if (x != 0) { assert (x | zero); assert (! (zero | x)); } for (int j = -n; j <= n; j ++) { R y (j); assert (- (-x) == x); assert (x + y == y + x); assert (x * y == y * x); if (x != 0 && x | y) { R q = y.div (x); assert (y == q * x); } if (x != 0 || y != 0) { triple t = x.extended_gcd (y); assert (t.first == t.second*x + t.third*y); } for (int k = -n; k <= n; k ++) { R z (k); assert ((x + y) + z == x + (y + z)); assert ((x * y) * z == x * (y * z)); assert (x*(y + z) == x*y + x*z); assert ((x + y)*z == x*z + y*z); } } } } template void test_field () { for (unsigned i = 1; i <= 8; i ++) for (unsigned j = 1; j <= rolfsen_crossing_knots (i); j ++) { knot_diagram kd (rolfsen_knot (i, j)); show (kd); newline (); cube c (kd); mod_map d = c.compute_d (1, 0, 0, 0, 0); assert (d.compose (d) == 0); ptr > H = d.homology (); display ("H:\n", *H); chain_complex_simplifier s (c.khC, d, 1); display ("s.new_C:\n", *s.new_C); assert (H->dim () == s.new_C->dim ()); } } int main () { test_ring (2); test_ring (0); test_ring > (2); test_ring > (3); test_ring > (5); test_ring > (7); test_field > (); test_field > (); test_field > (); test_field (); test_field > (); }