From 95ebd2d6acfa744c5e93287cc6385f4f1359376e Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Sun, 30 Oct 2022 03:42:11 +1300 Subject: wallgen and wallsolve working, visualwall partially done, license added --- src/polytest.ml | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/polytest.ml (limited to 'src/polytest.ml') diff --git a/src/polytest.ml b/src/polytest.ml new file mode 100644 index 0000000..c378279 --- /dev/null +++ b/src/polytest.ml @@ -0,0 +1,51 @@ + + +(* Programmed by Jedidiah Barber *) +(* Licensed under the Sunset License v1.0 *) + + +let _ = + let p1 = Poly.of_list Z.( [(~$1,~$2);(~$7,~$1);(~$3,~$0)] ) in + print_string "dividend: "; Poly.print p1; print_newline (); + + let p2 = Poly.of_list Z.( [(~$1,~$1);(~$(-1),~$0)] ) in + print_string "divisor: "; Poly.print p2; print_newline (); + + let (p3,p4) = Poly.div_rem p1 p2 in + print_string "quotient: "; Poly.print p3; print_newline (); + print_string "remainder: "; Poly.print p4; print_newline (); + + let p5 = Poly.add (Poly.mul p3 p2) p4 in + print_string "reconstituted: "; Poly.print p5; print_newline (); + + print_newline (); + + let p6 = Poly.of_list Z.( [(~$(-3),~$2);(~$7,~$0)] ) in + print_string "dividend: "; Poly.print p6; print_newline (); + + let p7 = Poly.of_list Z.( [(~$2,~$1);(~$2,~$0)] ) in + print_string "divisor: "; Poly.print p7; print_newline (); + + let (p8,p9) = Poly.div_rem p6 p7 in + print_string "quotient: "; Poly.print p8; print_newline (); + print_string "remainder: "; Poly.print p9; print_newline (); + + let p10 = Poly.add (Poly.mul p8 p7) p9 in + print_string "reconstituted: "; Poly.print p10; print_newline (); + + print_newline (); + + let p11 = Poly.of_list Z.( [(~$1,~$8);(~$(-1),~$0)] ) in + print_string "dividend: "; Poly.print p11; print_newline (); + + let p12 = Poly.of_list Z.( [(~$1,~$1);(~$(-1),~$0)] ) in + print_string "divisor: "; Poly.print p12; print_newline (); + + let (p13,p14) = Poly.div_rem p11 p12 in + print_string "quotient: "; Poly.print p13; print_newline (); + print_string "remainder: "; Poly.print p14; print_newline (); + + let p15 = Poly.add (Poly.mul p13 p12) p14 in + print_string "reconstituted: "; Poly.print p15; print_newline (); + + -- cgit