10 (* tests*) |
10 (* tests*) |
11 print("\n\n********************* tests *************************\n\n"); |
11 print("\n\n********************* tests *************************\n\n"); |
12 print("\n\n***** divide tests *****\n"); |
12 print("\n\n***** divide tests *****\n"); |
13 val mv_pquot1 = (#1(mv_division([(1,[1,1,1]),(1,[1,1,0]),(1,[1,0,1]),(1,[0,0,0])],[(1,[1,1,0]),(1,[0,0,0])],LEX_))); |
13 val mv_pquot1 = (#1(mv_division([(1,[1,1,1]),(1,[1,1,0]),(1,[1,0,1]),(1,[0,0,0])],[(1,[1,1,0]),(1,[0,0,0])],LEX_))); |
14 (* result: [(1,[0,0,1]),(1,[0,0,0])] *) |
14 (* result: [(1,[0,0,1]),(1,[0,0,0])] *) |
15 if mv_pquot1=[(1,[0,0,1]),(1,[0,0,0])] then () else raise error ("Test failed"); |
15 if mv_pquot1=[(1,[0,0,1]),(1,[0,0,0])] then () else error ("Test failed"); |
16 |
16 |
17 val mv_prest1 = (#2(mv_division([(1,[1,1,1]),(1,[1,1,0]),(1,[1,0,1]),(1,[0,0,0])],[(1,[1,1,0]),(1,[0,0,0])],LEX_))); |
17 val mv_prest1 = (#2(mv_division([(1,[1,1,1]),(1,[1,1,0]),(1,[1,0,1]),(1,[0,0,0])],[(1,[1,1,0]),(1,[0,0,0])],LEX_))); |
18 (* result: [(1,[1,0,1]),(~1,[0,0,1])] *) |
18 (* result: [(1,[1,0,1]),(~1,[0,0,1])] *) |
19 if mv_prest1=[(1,[1,0,1]),(~1,[0,0,1])] then () else raise error ("Test failed"); |
19 if mv_prest1=[(1,[1,0,1]),(~1,[0,0,1])] then () else error ("Test failed"); |
20 |
20 |
21 val mv_pquot2 = (#1(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_))); |
21 val mv_pquot2 = (#1(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_))); |
22 (* result: [(4,[1]),(4,[0])] *) |
22 (* result: [(4,[1]),(4,[0])] *) |
23 if mv_pquot2=[(4,[1]),(4,[0])] then () else raise error ("Test failed"); |
23 if mv_pquot2=[(4,[1]),(4,[0])] then () else error ("Test failed"); |
24 |
24 |
25 val mv_prest2 = (#2(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_))); |
25 val mv_prest2 = (#2(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_))); |
26 (* result: [(12,[0]] *) |
26 (* result: [(12,[0]] *) |
27 if mv_prest2=[(12,[0])] then () else raise error ("Test failed"); |
27 if mv_prest2=[(12,[0])] then () else error ("Test failed"); |
28 |
28 |
29 val mv_pquot3 = (#1(mv_division([(4,[2]),(~4,[0])],[(2,[1]),(2,[0])],LEX_))); |
29 val mv_pquot3 = (#1(mv_division([(4,[2]),(~4,[0])],[(2,[1]),(2,[0])],LEX_))); |
30 (* [(2,[1]),(~2,[0])] *) |
30 (* [(2,[1]),(~2,[0])] *) |
31 if mv_pquot3=[(2,[1]),(~2,[0])] then () else raise error ("Test failed"); |
31 if mv_pquot3=[(2,[1]),(~2,[0])] then () else error ("Test failed"); |
32 |
32 |
33 val mv_prest3 = (#2(mv_division([(1,[2]),(~1,[0])],[(2,[1]),(2,[0])],LEX_))); |
33 val mv_prest3 = (#2(mv_division([(1,[2]),(~1,[0])],[(2,[1]),(2,[0])],LEX_))); |
34 (* [(1,[2]),(~1,[0])] *) |
34 (* [(1,[2]),(~1,[0])] *) |
35 if mv_prest3=[(1,[2]),(~1,[0])] then () else raise error ("Test failed"); |
35 if mv_prest3=[(1,[2]),(~1,[0])] then () else error ("Test failed"); |
36 |
36 |
37 val mv_pquot4 = (#1(mv_division([(3,[1,1,1]),(4,[1,0,1]),(3,[0,0,1])],[(2,[1,0,0]),(4,[0,0,1])],LEX_))); |
37 val mv_pquot4 = (#1(mv_division([(3,[1,1,1]),(4,[1,0,1]),(3,[0,0,1])],[(2,[1,0,0]),(4,[0,0,1])],LEX_))); |
38 (* [(1,[0,1,1])] *) |
38 (* [(1,[0,1,1])] *) |
39 if mv_pquot4=[(1,[0,1,1])] then () else raise error ("Test failed"); |
39 if mv_pquot4=[(1,[0,1,1])] then () else error ("Test failed"); |
40 |
40 |
41 val mv_prest4 = (#2(mv_division([(3,[1,1,1]),(4,[1,0,1]),(3,[0,0,1])],[(2,[1,0,0]),(4,[0,0,1])],GGO_))); |
41 val mv_prest4 = (#2(mv_division([(3,[1,1,1]),(4,[1,0,1]),(3,[0,0,1])],[(2,[1,0,0]),(4,[0,0,1])],GGO_))); |
42 (* [(1,[1,1,1]),(~4,[0,1,2]),(4,[1,0,1]),(3,[0,0,1])] *) |
42 (* [(1,[1,1,1]),(~4,[0,1,2]),(4,[1,0,1]),(3,[0,0,1])] *) |
43 if mv_prest4 =[(1,[1,1,1]),(~4,[0,1,2]),(4,[1,0,1]),(3,[0,0,1])] then () else raise error ("Test failed"); |
43 if mv_prest4 =[(1,[1,1,1]),(~4,[0,1,2]),(4,[1,0,1]),(3,[0,0,1])] then () else error ("Test failed"); |
44 |
44 |
45 val mv_pquot5 = (#1(mv_division([(3,[1,1,1]),(4,[1,0,1]),(3,[0,0,1]),(6,[2,1,3]),(4,[0,4,1]),(1,[2,2,1])],[(1,[0,0,1])],LEX_))); |
45 val mv_pquot5 = (#1(mv_division([(3,[1,1,1]),(4,[1,0,1]),(3,[0,0,1]),(6,[2,1,3]),(4,[0,4,1]),(1,[2,2,1])],[(1,[0,0,1])],LEX_))); |
46 (* [(1,[2,2,0]),(6,[2,1,2]),(3,[1,1,0]),(4,[1,0,0]),(4,[0,4,0]),(3,[0,0,0])]*) |
46 (* [(1,[2,2,0]),(6,[2,1,2]),(3,[1,1,0]),(4,[1,0,0]),(4,[0,4,0]),(3,[0,0,0])]*) |
47 if mv_pquot5=[(1,[2,2,0]),(6,[2,1,2]),(3,[1,1,0]),(4,[1,0,0]),(4,[0,4,0]),(3,[0,0,0])] then () else raise error ("Test failed"); |
47 if mv_pquot5=[(1,[2,2,0]),(6,[2,1,2]),(3,[1,1,0]),(4,[1,0,0]),(4,[0,4,0]),(3,[0,0,0])] then () else error ("Test failed"); |
48 |
48 |
49 val mv_prest5 = (#2(mv_division([(3,[1,1,1]),(4,[1,0,1]),(3,[0,0,1]),(6,[2,1,3]),(4,[0,4,1]),(1,[2,2,1])],[(1,[0,0,1])],LEX_))); |
49 val mv_prest5 = (#2(mv_division([(3,[1,1,1]),(4,[1,0,1]),(3,[0,0,1]),(6,[2,1,3]),(4,[0,4,1]),(1,[2,2,1])],[(1,[0,0,1])],LEX_))); |
50 (* [] *) |
50 (* [] *) |
51 if mv_prest5=[] then () else raise error ("Test failed"); |
51 if mv_prest5=[] then () else error ("Test failed"); |
52 |
52 |
53 (* (x^2 + 2(a+1)x + (a^2+2a+1)) / (x+a+1) = x+a+1 *) |
53 (* (x^2 + 2(a+1)x + (a^2+2a+1)) / (x+a+1) = x+a+1 *) |
54 val mv_pquot6 = (#1(mv_division([(1,[2,0,0]),(2,[1,1,0]),(2,[1,0,0]),(1,[0,2,0]),(2,[0,1,0]),(1,[0,0,0])],[(1,[1,0,0]),(1,[0,1,0]),(1,[0,0,0])],LEX_))); |
54 val mv_pquot6 = (#1(mv_division([(1,[2,0,0]),(2,[1,1,0]),(2,[1,0,0]),(1,[0,2,0]),(2,[0,1,0]),(1,[0,0,0])],[(1,[1,0,0]),(1,[0,1,0]),(1,[0,0,0])],LEX_))); |
55 if mv_pquot6=[(1,[1,0,0]),(1,[0,1,0]),(1,[0,0,0])] then () else raise error ("Test failed"); |
55 if mv_pquot6=[(1,[1,0,0]),(1,[0,1,0]),(1,[0,0,0])] then () else error ("Test failed"); |
56 |
56 |
57 val mv_prest6 = (#2(mv_division([(1,[2,0,0]),(2,[1,1,0]),(2,[1,0,0]),(1,[0,2,0]),(2,[0,1,0]),(1,[0,0,0])],[(1,[1,0,0]),(1,[0,1,0]),(1,[0,0,0])],LEX_))); |
57 val mv_prest6 = (#2(mv_division([(1,[2,0,0]),(2,[1,1,0]),(2,[1,0,0]),(1,[0,2,0]),(2,[0,1,0]),(1,[0,0,0])],[(1,[1,0,0]),(1,[0,1,0]),(1,[0,0,0])],LEX_))); |
58 if mv_prest6=[] then () else raise error ("Test failed"); |
58 if mv_prest6=[] then () else error ("Test failed"); |
59 |
59 |
60 (* Exception tests *) |
60 (* Exception tests *) |
61 (* mv_division ([(1,[0,0,0])],[(0,[1,2,3])],LEX_); *) |
61 (* mv_division ([(1,[0,0,0])],[(0,[1,2,3])],LEX_); *) |
62 |
62 |
63 print("\n\n***** MV_CONTENT-TESTS *****\n"); |
63 print("\n\n***** MV_CONTENT-TESTS *****\n"); |
64 val mv_cont1=mv_content([(1,[2,1]),(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]); |
64 val mv_cont1=mv_content([(1,[2,1]),(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]); |
65 (* [(1,[0,1]),(1,[0,0])] *) |
65 (* [(1,[0,1]),(1,[0,0])] *) |
66 if mv_cont1=[(1,[0,1]),(1,[0,0])] then () else raise error ("Test failed"); |
66 if mv_cont1=[(1,[0,1]),(1,[0,0])] then () else error ("Test failed"); |
67 |
67 |
68 val mv_pp1=mv_pp([(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]); |
68 val mv_pp1=mv_pp([(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]); |
69 (*[(1,[1,0]),(1,[0,0])]*) |
69 (*[(1,[1,0]),(1,[0,0])]*) |
70 if mv_pp1=[(1,[1,0]),(1,[0,0])] then () else raise error ("Test failed"); |
70 if mv_pp1=[(1,[1,0]),(1,[0,0])] then () else error ("Test failed"); |
71 |
71 |
72 val mv_cont2=mv_content([(2,[1]),(4,[0])]); |
72 val mv_cont2=mv_content([(2,[1]),(4,[0])]); |
73 (* [(2,[0])] *) |
73 (* [(2,[0])] *) |
74 if mv_cont2=[(2,[0])] then () else raise error ("Test failed"); |
74 if mv_cont2=[(2,[0])] then () else error ("Test failed"); |
75 |
75 |
76 val mv_pp2=mv_pp([(2,[1]),(4,[0])]); |
76 val mv_pp2=mv_pp([(2,[1]),(4,[0])]); |
77 (* [(1,[1]),(2,[0])] *) |
77 (* [(1,[1]),(2,[0])] *) |
78 if mv_pp2=[(1,[1]),(2,[0])] then () else raise error ("Test failed"); |
78 if mv_pp2=[(1,[1]),(2,[0])] then () else error ("Test failed"); |
79 |
79 |
80 val mv_cont3=mv_content[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])]; |
80 val mv_cont3=mv_content[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])]; |
81 (* [(2,[0,0,0])] *) |
81 (* [(2,[0,0,0])] *) |
82 if mv_cont3=[(2,[0,0,0])] then () else raise error ("Test failed"); |
82 if mv_cont3=[(2,[0,0,0])] then () else error ("Test failed"); |
83 |
83 |
84 val mv_pp3=mv_pp[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])]; |
84 val mv_pp3=mv_pp[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])]; |
85 (* [(5,[2,2,0]),(4,[2,1,1]),(8,[1,1,1]),(6,[1,0,2])] *) |
85 (* [(5,[2,2,0]),(4,[2,1,1]),(8,[1,1,1]),(6,[1,0,2])] *) |
86 if mv_pp3=[(5,[2,2,0]),(4,[2,1,1]),(8,[1,1,1]),(6,[1,0,2])] then () else raise error ("Test failed"); |
86 if mv_pp3=[(5,[2,2,0]),(4,[2,1,1]),(8,[1,1,1]),(6,[1,0,2])] then () else error ("Test failed"); |
87 |
87 |
88 val mv_cont4=mv_content[(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])]; |
88 val mv_cont4=mv_content[(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])]; |
89 (* [(1,[0,0,0])] *) |
89 (* [(1,[0,0,0])] *) |
90 if mv_cont4=[(1,[0,0,0])] then () else raise error ("Test failed"); |
90 if mv_cont4=[(1,[0,0,0])] then () else error ("Test failed"); |
91 |
91 |
92 val mv_pp4=mv_pp [(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])]; |
92 val mv_pp4=mv_pp [(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])]; |
93 (* [(2,[2,1,0]),(2,[1,1,0]),(3,[1,0,1]),(3,[0,0,1])] *) |
93 (* [(2,[2,1,0]),(2,[1,1,0]),(3,[1,0,1]),(3,[0,0,1])] *) |
94 if mv_pp4=[(2,[2,1,0]),(2,[1,1,0]),(3,[1,0,1]),(3,[0,0,1])] then () else raise error ("Test failed"); |
94 if mv_pp4=[(2,[2,1,0]),(2,[1,1,0]),(3,[1,0,1]),(3,[0,0,1])] then () else error ("Test failed"); |
95 |
95 |
96 val con1=mv_content([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]); |
96 val con1=mv_content([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]); |
97 (* [(3,[0,0])] *) |
97 (* [(3,[0,0])] *) |
98 if con1=[(3,[0,0])] then () else raise error ("Test failed"); |
98 if con1=[(3,[0,0])] then () else error ("Test failed"); |
99 |
99 |
100 val pp1=mv_pp([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]); |
100 val pp1=mv_pp([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]); |
101 (* [(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] *) |
101 (* [(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] *) |
102 if pp1=[(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] then () else raise error ("Test failed"); |
102 if pp1=[(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] then () else error ("Test failed"); |
103 |
103 |
104 val con2=mv_content([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]); |
104 val con2=mv_content([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]); |
105 (* [(1,[0,0])] *) |
105 (* [(1,[0,0])] *) |
106 if con2=[(1,[0,0])] then () else raise error ("Test failed"); |
106 if con2=[(1,[0,0])] then () else error ("Test failed"); |
107 |
107 |
108 val pp2 =mv_pp([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]); |
108 val pp2 =mv_pp([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]); |
109 (* [(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] *) |
109 (* [(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] *) |
110 if pp2=[(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] then () else raise error ("Test failed"); |
110 if pp2=[(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] then () else error ("Test failed"); |
111 |
111 |
112 val cont1 = mv_content [(1,[2,1,0]),(2,[2,1,0])]; |
112 val cont1 = mv_content [(1,[2,1,0]),(2,[2,1,0])]; |
113 (* [(3,[0,1,0])] *) |
113 (* [(3,[0,1,0])] *) |
114 if cont1=[(3,[0,1,0])] then () else raise error ("Test failed"); |
114 if cont1=[(3,[0,1,0])] then () else error ("Test failed"); |
115 |
115 |
116 val pp1 = mv_pp [(1,[2,1,0]),(2,[2,1,0])]; |
116 val pp1 = mv_pp [(1,[2,1,0]),(2,[2,1,0])]; |
117 (* [(1,[2,0,0])] *) |
117 (* [(1,[2,0,0])] *) |
118 if pp1=[(1,[2,0,0])] then () else raise error ("Test failed"); |
118 if pp1=[(1,[2,0,0])] then () else error ("Test failed"); |
119 |
119 |
120 val cont2 = mv_content [(4,[1,2,0]),(2,[2,1,0])]; |
120 val cont2 = mv_content [(4,[1,2,0]),(2,[2,1,0])]; |
121 (* [(2,[0,1,0])] *) |
121 (* [(2,[0,1,0])] *) |
122 if cont2=[(2,[0,1,0])] then () else raise error ("Test failed"); |
122 if cont2=[(2,[0,1,0])] then () else error ("Test failed"); |
123 |
123 |
124 val pp2 = mv_pp [(4,[1,2,0]),(2,[2,1,0])]; |
124 val pp2 = mv_pp [(4,[1,2,0]),(2,[2,1,0])]; |
125 (* [(1,[2,0,0]),(2,[1,1,0])] *) |
125 (* [(1,[2,0,0]),(2,[1,1,0])] *) |
126 if pp2=[(1,[2,0,0]),(2,[1,1,0])] then () else raise error ("Test failed"); |
126 if pp2=[(1,[2,0,0]),(2,[1,1,0])] then () else error ("Test failed"); |
127 |
127 |
128 print("\n\n\n\n********************************************************\n\n"); |
128 print("\n\n\n\n********************************************************\n\n"); |
129 val cont3=mv_content [(65,[3,2,2]),(52,[3,2,1]),(26,[3,1,2]),(~95,[2,2,3]),(~76,[2,2,2]),(35,[2,2,1]),(28,[2,2,0]),(~38,[2,1,3]),(14,[2,1,1])]; |
129 val cont3=mv_content [(65,[3,2,2]),(52,[3,2,1]),(26,[3,1,2]),(~95,[2,2,3]),(~76,[2,2,2]),(35,[2,2,1]),(28,[2,2,0]),(~38,[2,1,3]),(14,[2,1,1])]; |
130 (*if cont3=[(1,[0,1,0])] then () else raise error ("Test failed"); *) |
130 (*if cont3=[(1,[0,1,0])] then () else error ("Test failed"); *) |
131 val pp3=mv_pp [(65,[3,2,2]),(52,[3,2,1]),(26,[3,1,2]),(~95,[2,2,3]),(~76,[2,2,2]),(35,[2,2,1]),(28,[2,2,0]),(~38,[2,1,3]),(14,[2,1,1])]; |
131 val pp3=mv_pp [(65,[3,2,2]),(52,[3,2,1]),(26,[3,1,2]),(~95,[2,2,3]),(~76,[2,2,2]),(35,[2,2,1]),(28,[2,2,0]),(~38,[2,1,3]),(14,[2,1,1])]; |
132 |
132 |
133 |
133 |
134 print("\n\n***** gcd-tests *****\n"); |
134 print("\n\n***** gcd-tests *****\n"); |
135 val ggt1 = gcd_poly [(4,[2,2]),(8,[1,1]),(4,[0,0])] [(2,[1,1]),(2,[0,0])]; |
135 val ggt1 = gcd_poly [(4,[2,2]),(8,[1,1]),(4,[0,0])] [(2,[1,1]),(2,[0,0])]; |
136 (* [(2,[1,1]),(2,[0,0])] *) |
136 (* [(2,[1,1]),(2,[0,0])] *) |
137 if ggt1=[(2,[1,1]),(2,[0,0])] then () else raise error ("Test failed"); |
137 if ggt1=[(2,[1,1]),(2,[0,0])] then () else error ("Test failed"); |
138 |
138 |
139 val ggt2 = gcd_poly [(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(15,[1,1,1])] [(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])]; |
139 val ggt2 = gcd_poly [(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(15,[1,1,1])] [(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])]; |
140 (* [(2,[1,1,0]),(3,[0,0,1])] *) |
140 (* [(2,[1,1,0]),(3,[0,0,1])] *) |
141 if ggt2=[(2,[1,1,0]),(3,[0,0,1])] then () else raise error ("Test failed"); |
141 if ggt2=[(2,[1,1,0]),(3,[0,0,1])] then () else error ("Test failed"); |
142 |
142 |
143 val ggt3 = gcd_poly [(1,[2,0,0]),(~2,[1,0,1]),(1,[0,0,2])] [(1,[1,0,0]),(~1,[0,0,1])]; |
143 val ggt3 = gcd_poly [(1,[2,0,0]),(~2,[1,0,1]),(1,[0,0,2])] [(1,[1,0,0]),(~1,[0,0,1])]; |
144 (* [(1,[1,0,0]),(~1,[0,0,1])] *) |
144 (* [(1,[1,0,0]),(~1,[0,0,1])] *) |
145 if ggt3=[(1,[1,0,0]),(~1,[0,0,1])] then () else raise error ("Test failed"); |
145 if ggt3=[(1,[1,0,0]),(~1,[0,0,1])] then () else error ("Test failed"); |
146 |
146 |
147 val ggt4 = gcd_poly [(1,[2,1,0]),(2,[2,1,0])] [(5,[1,0,0])]; |
147 val ggt4 = gcd_poly [(1,[2,1,0]),(2,[2,1,0])] [(5,[1,0,0])]; |
148 (* [(1,[1,0,0])] *) |
148 (* [(1,[1,0,0])] *) |
149 if ggt4=[(1,[1,0,0])] then () else raise error ("Test failed"); |
149 if ggt4=[(1,[1,0,0])] then () else error ("Test failed"); |
150 |
150 |
151 val ggt5 = gcd_poly [(4,[2,0,0]),(~8,[1,0,1]),(4,[0,0,2])] [(1,[2,0,0]),(~1,[0,0,2])]; |
151 val ggt5 = gcd_poly [(4,[2,0,0]),(~8,[1,0,1]),(4,[0,0,2])] [(1,[2,0,0]),(~1,[0,0,2])]; |
152 (* [(1,[1,0,0]),(~1,[0,0,1])] *) |
152 (* [(1,[1,0,0]),(~1,[0,0,1])] *) |
153 if ggt5=[(1,[1,0,0]),(~1,[0,0,1])] then () else raise error ("Test failed"); |
153 if ggt5=[(1,[1,0,0]),(~1,[0,0,1])] then () else error ("Test failed"); |
154 |
154 |
155 val ggt6 = gcd_poly [(10,[2,1,1]),(14,[1,1,0]),(3,[1,0,1]),(20,[1,2,1])] [(5,[1,1,1]),(7,[2,1,1])]; |
155 val ggt6 = gcd_poly [(10,[2,1,1]),(14,[1,1,0]),(3,[1,0,1]),(20,[1,2,1])] [(5,[1,1,1]),(7,[2,1,1])]; |
156 (* [(1,[0,0,0])] *) |
156 (* [(1,[0,0,0])] *) |
157 if ggt6=[(1,[1,0,0])] then () else raise error ("Test failed"); |
157 if ggt6=[(1,[1,0,0])] then () else error ("Test failed"); |
158 |
158 |
159 val ggt7 = gcd_poly [(~169,[4,3,3]),(273,[4,2,2]),(247,[3,3,4]),(~91,[3,3,2]),(78,[3,3,1]),(~399,[3,2,3]),(147,[3,2,1]),(~114,[2,3,2]),(42,[2,3,0])] [(65,[3,2,2]),(52,[3,2,1]),(26,[3,1,2]),(~95,[2,2,3]),(~76,[2,2,2]),(35,[2,2,1]),(28,[2,2,0]),(~38,[2,1,3]),(14,[2,1,1])]; |
159 val ggt7 = gcd_poly [(~169,[4,3,3]),(273,[4,2,2]),(247,[3,3,4]),(~91,[3,3,2]),(78,[3,3,1]),(~399,[3,2,3]),(147,[3,2,1]),(~114,[2,3,2]),(42,[2,3,0])] [(65,[3,2,2]),(52,[3,2,1]),(26,[3,1,2]),(~95,[2,2,3]),(~76,[2,2,2]),(35,[2,2,1]),(28,[2,2,0]),(~38,[2,1,3]),(14,[2,1,1])]; |
160 (* [(13,[3,1,1]),(~19,[2,1,2]),(7,[2,1,0])] *) |
160 (* [(13,[3,1,1]),(~19,[2,1,2]),(7,[2,1,0])] *) |
161 if ggt7=[(13,[3,1,1]),(~19,[2,1,2]),(7,[2,1,0])] then () else raise error ("Test failed"); |
161 if ggt7=[(13,[3,1,1]),(~19,[2,1,2]),(7,[2,1,0])] then () else error ("Test failed"); |
162 |
162 |
163 print("\n\n***** kgv-tests *****\n"); |
163 print("\n\n***** kgv-tests *****\n"); |
164 val kgv1=lcm_poly [(10,[])] [(15,[])]; |
164 val kgv1=lcm_poly [(10,[])] [(15,[])]; |
165 (* [(30,[])] *) |
165 (* [(30,[])] *) |
166 if kgv1=[(30,[])] then () else raise error ("Test failed"); |
166 if kgv1=[(30,[])] then () else error ("Test failed"); |
167 |
167 |
168 val kgv2=lcm_poly [(1,[2,0,0]),(~2,[1,0,1]),(1,[0,0,2])] [(1,[1,0,0]),(~1,[0,0,1])]; |
168 val kgv2=lcm_poly [(1,[2,0,0]),(~2,[1,0,1]),(1,[0,0,2])] [(1,[1,0,0]),(~1,[0,0,1])]; |
169 (* [(1,[2,0,0]),(~2,[1,0,1]),(1,[0,0,2])] *) |
169 (* [(1,[2,0,0]),(~2,[1,0,1]),(1,[0,0,2])] *) |
170 if kgv2=[(1,[2,0,0]),(~2,[1,0,1]),(1,[0,0,2])] then () else raise error ("Test failed"); |
170 if kgv2=[(1,[2,0,0]),(~2,[1,0,1]),(1,[0,0,2])] then () else error ("Test failed"); |
171 |
171 |
172 val kgv3=lcm_poly [(4,[2,0,0]),(~8,[1,0,1]),(4,[0,0,2])] [(1,[2,0,0]),(~1,[0,0,2])]; |
172 val kgv3=lcm_poly [(4,[2,0,0]),(~8,[1,0,1]),(4,[0,0,2])] [(1,[2,0,0]),(~1,[0,0,2])]; |
173 (* [(4,[3,0,0]),(~4,[2,0,1]),(~4,[1,0,2]),(4,[0,0,3])] *) |
173 (* [(4,[3,0,0]),(~4,[2,0,1]),(~4,[1,0,2]),(4,[0,0,3])] *) |
174 if kgv3=[(4,[3,0,0]),(~4,[2,0,1]),(~4,[1,0,2]),(4,[0,0,3])] then () else raise error ("Test failed"); |
174 if kgv3=[(4,[3,0,0]),(~4,[2,0,1]),(~4,[1,0,2]),(4,[0,0,3])] then () else error ("Test failed"); |
175 |
175 |
176 (* |
176 (* |
177 print("***** TERM2POLY-TESTS *****\n"); |
177 print("***** TERM2POLY-TESTS *****\n"); |
178 val t0 = (term_of o the o (parse thy)) "3 * 4"; |
178 val t0 = (term_of o the o (parse thy)) "3 * 4"; |
179 val t1 = (term_of o the o (parse thy)) "27"; |
179 val t1 = (term_of o the o (parse thy)) "27"; |