class TestToomCook(unittest.TestCase):
def test_toom_2(self):
TOOM_2 = ToomCookInstance.make_toom_2()
- print(repr(repr(TOOM_2)))
+ # print(repr(repr(TOOM_2)))
self.assertEqual(
repr(TOOM_2),
"ToomCookInstance(lhs_part_count=2, rhs_part_count=2, "
"EvalOpInput(lhs=2, rhs=0, poly=EvalOpPoly({2: Fraction(1, 1)}))))"
)
+ def test_toom_2_5(self):
+ TOOM_2_5 = ToomCookInstance.make_toom_2_5()
+ # print(repr(repr(TOOM_2_5)))
+ self.assertEqual(
+ repr(TOOM_2_5),
+ "ToomCookInstance(lhs_part_count=3, rhs_part_count=2, "
+ "eval_points=(0, 1, -1, POINT_AT_INFINITY), lhs_eval_ops=("
+ "EvalOpInput(lhs=0, rhs=0, poly=EvalOpPoly({0: Fraction(1, 1)})), "
+ "EvalOpAdd(lhs="
+ "EvalOpAdd(lhs="
+ "EvalOpInput(lhs=0, rhs=0, poly=EvalOpPoly({0: Fraction(1, 1)})), "
+ "rhs=EvalOpInput(lhs=2, rhs=0, "
+ "poly=EvalOpPoly({2: Fraction(1, 1)})), "
+ "poly=EvalOpPoly({0: Fraction(1, 1), 2: Fraction(1, 1)})), "
+ "rhs=EvalOpInput(lhs=1, rhs=0, "
+ "poly=EvalOpPoly({1: Fraction(1, 1)})), "
+ "poly=EvalOpPoly({"
+ "0: Fraction(1, 1), 1: Fraction(1, 1), 2: Fraction(1, 1)})), "
+ "EvalOpSub(lhs="
+ "EvalOpAdd(lhs="
+ "EvalOpInput(lhs=0, rhs=0, poly=EvalOpPoly({0: Fraction(1, 1)})), "
+ "rhs=EvalOpInput(lhs=2, rhs=0, "
+ "poly=EvalOpPoly({2: Fraction(1, 1)})), "
+ "poly=EvalOpPoly({0: Fraction(1, 1), 2: Fraction(1, 1)})), "
+ "rhs=EvalOpInput(lhs=1, rhs=0, "
+ "poly=EvalOpPoly({1: Fraction(1, 1)})), poly=EvalOpPoly("
+ "{0: Fraction(1, 1), 1: Fraction(-1, 1), 2: Fraction(1, 1)})), "
+ "EvalOpInput(lhs=2, rhs=0, "
+ "poly=EvalOpPoly({2: Fraction(1, 1)}))), rhs_eval_ops=("
+ "EvalOpInput(lhs=0, rhs=0, poly=EvalOpPoly({0: Fraction(1, 1)})), "
+ "EvalOpAdd(lhs=EvalOpInput(lhs=0, rhs=0, "
+ "poly=EvalOpPoly({0: Fraction(1, 1)})), rhs="
+ "EvalOpInput(lhs=1, rhs=0, poly=EvalOpPoly({1: Fraction(1, 1)})), "
+ "poly=EvalOpPoly({0: Fraction(1, 1), 1: Fraction(1, 1)})), "
+ "EvalOpSub(lhs="
+ "EvalOpInput(lhs=0, rhs=0, poly=EvalOpPoly({0: Fraction(1, 1)})), "
+ "rhs=EvalOpInput(lhs=1, rhs=0, "
+ "poly=EvalOpPoly({1: Fraction(1, 1)})), "
+ "poly=EvalOpPoly({0: Fraction(1, 1), 1: Fraction(-1, 1)})), "
+ "EvalOpInput(lhs=1, rhs=0, "
+ "poly=EvalOpPoly({1: Fraction(1, 1)}))), "
+ "prod_eval_ops=("
+ "EvalOpInput(lhs=0, rhs=0, poly=EvalOpPoly({0: Fraction(1, 1)})), "
+ "EvalOpSub(lhs=EvalOpExactDiv(lhs=EvalOpSub(lhs="
+ "EvalOpInput(lhs=1, rhs=0, poly=EvalOpPoly({1: Fraction(1, 1)})), "
+ "rhs=EvalOpInput(lhs=2, rhs=0, "
+ "poly=EvalOpPoly({2: Fraction(1, 1)})), "
+ "poly=EvalOpPoly({1: Fraction(1, 1), 2: Fraction(-1, 1)})), "
+ "rhs=2, "
+ "poly=EvalOpPoly({1: Fraction(1, 2), 2: Fraction(-1, 2)})), rhs="
+ "EvalOpInput(lhs=3, rhs=0, poly=EvalOpPoly({3: Fraction(1, 1)})), "
+ "poly=EvalOpPoly("
+ "{1: Fraction(1, 2), 2: Fraction(-1, 2), 3: Fraction(-1, 1)})), "
+ "EvalOpSub(lhs=EvalOpExactDiv(lhs=EvalOpAdd(lhs="
+ "EvalOpInput(lhs=1, rhs=0, poly=EvalOpPoly({1: Fraction(1, 1)})), "
+ "rhs="
+ "EvalOpInput(lhs=2, rhs=0, poly=EvalOpPoly({2: Fraction(1, 1)})), "
+ "poly=EvalOpPoly({1: Fraction(1, 1), 2: Fraction(1, 1)})), rhs=2, "
+ "poly=EvalOpPoly({1: Fraction(1, 2), 2: Fraction(1, 2)})), rhs="
+ "EvalOpInput(lhs=0, rhs=0, poly=EvalOpPoly({0: Fraction(1, 1)})), "
+ "poly=EvalOpPoly("
+ "{0: Fraction(-1, 1), 1: Fraction(1, 2), 2: Fraction(1, 2)})), "
+ "EvalOpInput(lhs=3, rhs=0, poly=EvalOpPoly({3: Fraction(1, 1)}))))"
+ )
+
+ def test_reversed_toom_2_5(self):
+ TOOM_2_5 = ToomCookInstance.make_toom_2_5().reversed()
+ print(repr(repr(TOOM_2_5)))
+ self.assertEqual(
+ repr(TOOM_2_5),
+ "ToomCookInstance(lhs_part_count=2, rhs_part_count=3, "
+ "eval_points=(0, 1, -1, POINT_AT_INFINITY), lhs_eval_ops=("
+ "EvalOpInput(lhs=0, rhs=0, poly=EvalOpPoly({0: Fraction(1, 1)})), "
+ "EvalOpAdd(lhs="
+ "EvalOpInput(lhs=0, rhs=0, poly=EvalOpPoly({0: Fraction(1, 1)})), "
+ "rhs="
+ "EvalOpInput(lhs=1, rhs=0, poly=EvalOpPoly({1: Fraction(1, 1)})), "
+ "poly=EvalOpPoly({0: Fraction(1, 1), 1: Fraction(1, 1)})), "
+ "EvalOpSub(lhs="
+ "EvalOpInput(lhs=0, rhs=0, poly=EvalOpPoly({0: Fraction(1, 1)})), "
+ "rhs="
+ "EvalOpInput(lhs=1, rhs=0, poly=EvalOpPoly({1: Fraction(1, 1)})), "
+ "poly=EvalOpPoly({0: Fraction(1, 1), 1: Fraction(-1, 1)})), "
+ "EvalOpInput(lhs=1, rhs=0, poly=EvalOpPoly({1: Fraction(1, 1)}))),"
+ " rhs_eval_ops=("
+ "EvalOpInput(lhs=0, rhs=0, poly=EvalOpPoly({0: Fraction(1, 1)})), "
+ "EvalOpAdd(lhs=EvalOpAdd(lhs="
+ "EvalOpInput(lhs=0, rhs=0, poly=EvalOpPoly({0: Fraction(1, 1)})), "
+ "rhs="
+ "EvalOpInput(lhs=2, rhs=0, poly=EvalOpPoly({2: Fraction(1, 1)})), "
+ "poly=EvalOpPoly({0: Fraction(1, 1), 2: Fraction(1, 1)})), rhs="
+ "EvalOpInput(lhs=1, rhs=0, poly=EvalOpPoly({1: Fraction(1, 1)})), "
+ "poly=EvalOpPoly("
+ "{0: Fraction(1, 1), 1: Fraction(1, 1), 2: Fraction(1, 1)})), "
+ "EvalOpSub(lhs=EvalOpAdd(lhs="
+ "EvalOpInput(lhs=0, rhs=0, poly=EvalOpPoly({0: Fraction(1, 1)})), "
+ "rhs="
+ "EvalOpInput(lhs=2, rhs=0, poly=EvalOpPoly({2: Fraction(1, 1)})), "
+ "poly=EvalOpPoly({0: Fraction(1, 1), 2: Fraction(1, 1)})), rhs="
+ "EvalOpInput(lhs=1, rhs=0, poly=EvalOpPoly({1: Fraction(1, 1)})), "
+ "poly=EvalOpPoly("
+ "{0: Fraction(1, 1), 1: Fraction(-1, 1), 2: Fraction(1, 1)})), "
+ "EvalOpInput(lhs=2, rhs=0, poly=EvalOpPoly({2: Fraction(1, 1)}))),"
+ " prod_eval_ops=("
+ "EvalOpInput(lhs=0, rhs=0, poly=EvalOpPoly({0: Fraction(1, 1)})), "
+ "EvalOpSub(lhs=EvalOpExactDiv(lhs=EvalOpSub(lhs="
+ "EvalOpInput(lhs=1, rhs=0, poly=EvalOpPoly({1: Fraction(1, 1)})), "
+ "rhs="
+ "EvalOpInput(lhs=2, rhs=0, poly=EvalOpPoly({2: Fraction(1, 1)})), "
+ "poly=EvalOpPoly({1: Fraction(1, 1), 2: Fraction(-1, 1)})), "
+ "rhs=2, "
+ "poly=EvalOpPoly({1: Fraction(1, 2), 2: Fraction(-1, 2)})), rhs="
+ "EvalOpInput(lhs=3, rhs=0, poly=EvalOpPoly({3: Fraction(1, 1)})), "
+ "poly=EvalOpPoly("
+ "{1: Fraction(1, 2), 2: Fraction(-1, 2), 3: Fraction(-1, 1)})), "
+ "EvalOpSub(lhs=EvalOpExactDiv(lhs=EvalOpAdd(lhs="
+ "EvalOpInput(lhs=1, rhs=0, poly=EvalOpPoly({1: Fraction(1, 1)})), "
+ "rhs="
+ "EvalOpInput(lhs=2, rhs=0, poly=EvalOpPoly({2: Fraction(1, 1)})), "
+ "poly=EvalOpPoly({1: Fraction(1, 1), 2: Fraction(1, 1)})), rhs=2, "
+ "poly=EvalOpPoly({1: Fraction(1, 2), 2: Fraction(1, 2)})), rhs="
+ "EvalOpInput(lhs=0, rhs=0, poly=EvalOpPoly({0: Fraction(1, 1)})), "
+ "poly=EvalOpPoly("
+ "{0: Fraction(-1, 1), 1: Fraction(1, 2), 2: Fraction(1, 2)})), "
+ "EvalOpInput(lhs=3, rhs=0, poly=EvalOpPoly({3: Fraction(1, 1)}))))"
+ )
+
if __name__ == "__main__":
unittest.main()