1 | // |
---|
2 | // gcdp_s.tst - short tests for gcd calculations mod p. |
---|
3 | // |
---|
4 | // All univariate non-trivial examples come from gcdUnivP.fex |
---|
5 | // or gcdUnivPAlpha.fex. |
---|
6 | // |
---|
7 | // The example in variables `a', `c', `e', ... came from `untitled2(6/p/1)' |
---|
8 | // in stdMultivPGcd.in. |
---|
9 | // |
---|
10 | // To Do: |
---|
11 | // |
---|
12 | // o multivariate gcd calculations with parameters |
---|
13 | // |
---|
14 | |
---|
15 | LIB "tst.lib"; |
---|
16 | tst_init(); |
---|
17 | |
---|
18 | // |
---|
19 | // - functions. |
---|
20 | // |
---|
21 | |
---|
22 | // |
---|
23 | // simplifyGcd() - print gcd as well as normalized gcd. |
---|
24 | // |
---|
25 | proc simplifyGcd ( poly f, poly g ) |
---|
26 | { |
---|
27 | poly d=gcd( f, g ); |
---|
28 | d; |
---|
29 | simplify( d, 1 ); |
---|
30 | } |
---|
31 | |
---|
32 | // |
---|
33 | // - ring r1=32003,x,dp. |
---|
34 | // |
---|
35 | |
---|
36 | tst_ignore( "ring r1=32003,x,dp;" ); |
---|
37 | ring r1=32003,x,dp; |
---|
38 | |
---|
39 | poly f=-9554*x^4-12895*x^3-10023*x^2-6213*x; |
---|
40 | poly g; |
---|
41 | |
---|
42 | // some trivial examples |
---|
43 | gcd(0, 0); |
---|
44 | gcd(0, 3123); |
---|
45 | gcd(4353, 0); |
---|
46 | simplifyGcd(0, 0); |
---|
47 | simplifyGcd(0, 3123); |
---|
48 | simplifyGcd(4353, 0); |
---|
49 | |
---|
50 | simplifyGcd(0, f); |
---|
51 | simplifyGcd(f, 0); |
---|
52 | |
---|
53 | simplifyGcd(23123, f); |
---|
54 | simplifyGcd(f, 13123); |
---|
55 | |
---|
56 | // some less trivial examples |
---|
57 | f=-9554*x^4-12895*x^3-10023*x^2-6213*x; |
---|
58 | g=-9554*x^3-3341*x^2+6213*x; |
---|
59 | simplifyGcd(f, g); |
---|
60 | |
---|
61 | f=-11265*x^6+12161*x^5+10369*x^4-12161*x^3+896*x^2; |
---|
62 | g=10669*x^8-10673*x^7+5*x^6+8*x^5-10681*x^4+10665*x^3+7*x^2; |
---|
63 | simplifyGcd(f, g); |
---|
64 | |
---|
65 | f=-7918*x^9-14406*x^8-7256*x^7+2092*x^6-2198*x^5-12539*x^4-14631*x^3-7150*x^2; |
---|
66 | g=-14833*x^13-7011*x^12+15121*x^11-10864*x^10+12943*x^9-9871*x^8+10354*x^7-1437*x^6+6604*x^5-10394*x^4-3231*x^3-9348*x^2-2092*x; |
---|
67 | simplifyGcd(f, g); |
---|
68 | |
---|
69 | // |
---|
70 | // - ring r2=(32003,a),x,dp; minpoly=a^4+8734*a^3+a^2+11817*a+1. |
---|
71 | // |
---|
72 | |
---|
73 | tst_ignore( "ring r2=(32003,a),x,dp;" ); |
---|
74 | ring r2=(32003,a),x,dp; |
---|
75 | minpoly=a^4+8734*a^3+a^2+11817*a+1; |
---|
76 | |
---|
77 | poly f=-9554*x^4-12895*x^3-10023*x^2-6213*x; |
---|
78 | poly g; |
---|
79 | |
---|
80 | // first, some of the r1 examples |
---|
81 | simplifyGcd(0, 0); |
---|
82 | simplifyGcd(0, 3123); |
---|
83 | simplifyGcd(4353, 0); |
---|
84 | |
---|
85 | simplifyGcd(0, f); |
---|
86 | simplifyGcd(f, 0); |
---|
87 | |
---|
88 | simplifyGcd(23123, f); |
---|
89 | simplifyGcd(f, 13123); |
---|
90 | |
---|
91 | // some less trivial examples |
---|
92 | f=-9554*x^4-12895*x^3-10023*x^2-6213*x; |
---|
93 | g=-9554*x^3-3341*x^2+6213*x; |
---|
94 | simplifyGcd(f, g); |
---|
95 | |
---|
96 | f=-11265*x^6+12161*x^5+10369*x^4-12161*x^3+896*x^2; |
---|
97 | g=10669*x^8-10673*x^7+5*x^6+8*x^5-10681*x^4+10665*x^3+7*x^2; |
---|
98 | simplifyGcd(f, g); |
---|
99 | |
---|
100 | // now, examples involving the algebraic variable |
---|
101 | f=(21147*a^3*x^5+10147*a^3*x^4+8142*a^2*x^4+27671*a*x^4+29289*x^4+29289*a^3*x^3); |
---|
102 | g=(6167*a^3*x^6+1536*a^2*x^6+5211*a*x^6+1536*x^6+17534*a^3*x^5+478*a^2*x^5+1536*a*x^5+19085*x^5+3203*a^3*x^4+26578*a^2*x^4+17052*a*x^4+26770*x^4+26002*a^3*x^3+24062*a^2*x^3+192*a*x^3+6386*x^3); |
---|
103 | simplifyGcd(f, g); |
---|
104 | |
---|
105 | f=(2295*a^2*x^11+5897*a^3*x^10+765*a^2*x^10+27718*a^3*x^9+1283*a^2*x^9+23792*a*x^9+518*x^9+22026*a^3*x^8+11468*a^2*x^8+16834*a*x^8+24778*x^8+28460*a^3*x^7+8140*a^2*x^7+28036*a*x^7+1613*x^7+18196*a^3*x^6+13274*a^2*x^6+4638*a*x^6+31194*x^6+12206*a^3*x^5+10349*a^2*x^5+30979*a*x^5+8612*x^5); |
---|
106 | g=(8192*a^3*x^10+8957*a^2*x^10+9659*a^3*x^9+28672*a^2*x^9+4553*a*x^9+12288*x^9+5819*a^3*x^8+320*a^2*x^8+14380*a*x^8+12104*x^8+12047*a^3*x^7+19823*a^2*x^7+6824*a*x^7+4335*x^7+29376*a^3*x^6+22190*a^2*x^6+31239*a*x^6+22647*x^6); |
---|
107 | simplifyGcd(f, g); |
---|
108 | |
---|
109 | // |
---|
110 | // - ring r3=(32003,t),x,dp. |
---|
111 | // |
---|
112 | |
---|
113 | tst_ignore( "ring r3=(32003,t),x,dp;" ); |
---|
114 | ring r3=(32003,t),x,dp; |
---|
115 | |
---|
116 | poly f=(-9554*x^4-12895*x^3-10023*x^2-6213*x); |
---|
117 | poly g; |
---|
118 | |
---|
119 | // first, some of the r1 examples (slightly modified) |
---|
120 | simplifyGcd(0, 0); |
---|
121 | simplifyGcd(0, 3123*t); |
---|
122 | simplifyGcd(4353, 0); |
---|
123 | |
---|
124 | simplifyGcd(0, f/t); |
---|
125 | simplifyGcd(f, 0); |
---|
126 | |
---|
127 | simplifyGcd(23123/t, f); |
---|
128 | simplifyGcd(f, 13123); |
---|
129 | |
---|
130 | // some less trivial examples |
---|
131 | f=-9554*x^4-12895*x^3-10023*x^2-6213*x; |
---|
132 | g=-9554*x^3-3341*x^2+6213*x; |
---|
133 | simplifyGcd(f, g); |
---|
134 | |
---|
135 | // we go on with modified variable names |
---|
136 | tst_ignore( "ring r3=(32003,a,c,e),(f,h,k),dp;" ); |
---|
137 | kill r3; |
---|
138 | ring r3=(32003,a,c,e),(f,h,k),dp; |
---|
139 | |
---|
140 | poly fPoly; |
---|
141 | poly gPoly; |
---|
142 | |
---|
143 | fPoly=(16001*c^2*f^2*k^2-16001*c*e*f*k^3+c*f^3*h*k-e*f^2*h*k^2); |
---|
144 | gPoly=(c^3*e*f*h-4*c*e^2*f*h^2); |
---|
145 | simplifyGcd(fPoly, gPoly); |
---|
146 | |
---|
147 | fPoly=(c^4*k^2-5*c^3*f*h*k+4*c^2*e*h*k^2+4*c^2*f^2*h^2-4*c*e*f*h^2*k); |
---|
148 | gPoly=(-c^3*f*k^2+c^2*e*k^3+2*c^2*f^2*h*k-2*c*e*f*h*k^2); |
---|
149 | simplifyGcd(fPoly, gPoly); |
---|
150 | |
---|
151 | fPoly=(-8001*c^4*e*f*k^6+8001*c^4*f^3*h*k^4+8001*c^3*e^2*k^7+8001*c^3*e*f^2*h*k^5+16001*c^3*f^4*h^2*k^3+16001*c^2*e^2*f*h*k^6-16001*c^2*e*f^3*h^2*k^4); |
---|
152 | gPoly=(16001*c^7*e*h*k^3-15998*c^6*e*f*h^2*k^2-7*c^5*e*f^2*h^3*k-8*c^4*e^2*f*h^3*k^2+4*c^4*e*f^3*h^4+8*c^3*e^3*h^3*k^3+24*c^3*e^2*f^2*h^4*k-24*c^2*e^3*f*h^4*k^2-16*c^2*e^2*f^3*h^5+16*c*e^3*f^2*h^5*k); |
---|
153 | simplifyGcd(fPoly, gPoly); |
---|
154 | |
---|
155 | // |
---|
156 | // - ring r4=32003,(t,x),dp. |
---|
157 | // |
---|
158 | // The examples from r4 are those from r3 with parameters |
---|
159 | // changed to ring variables. |
---|
160 | // |
---|
161 | |
---|
162 | tst_ignore( "ring r4=32003,(t,x),dp;" ); |
---|
163 | ring r4=32003,(t,x),dp; |
---|
164 | |
---|
165 | poly f=(-9554*x^4-12895*x^3-10023*x^2-6213*x); |
---|
166 | poly g; |
---|
167 | |
---|
168 | // first, some of the r1 examples (slightly modified) |
---|
169 | simplifyGcd(0, 0); |
---|
170 | simplifyGcd(0, 3123*t); |
---|
171 | simplifyGcd(4353, 0); |
---|
172 | |
---|
173 | simplifyGcd(0, f); |
---|
174 | simplifyGcd(f, 0); |
---|
175 | |
---|
176 | simplifyGcd(23123*t, f); |
---|
177 | simplifyGcd(f, 13123); |
---|
178 | |
---|
179 | // some less trivial examples |
---|
180 | f=-9554*x^4-12895*x^3-10023*x^2-6213*x; |
---|
181 | g=-9554*x^3-3341*x^2+6213*x; |
---|
182 | simplifyGcd(t*f, g); |
---|
183 | |
---|
184 | // we go on with modified variable names |
---|
185 | tst_ignore( "ring r4=32003,(a,c,e,f,h,k),dp;" ); |
---|
186 | kill r4; |
---|
187 | ring r4=32003,(a,c,e,f,h,k),dp; |
---|
188 | |
---|
189 | poly fPoly; |
---|
190 | poly gPoly; |
---|
191 | |
---|
192 | fPoly=(16001*c^2*f^2*k^2-16001*c*e*f*k^3+c*f^3*h*k-e*f^2*h*k^2); |
---|
193 | gPoly=(c^3*e*f*h-4*c*e^2*f*h^2); |
---|
194 | simplifyGcd(fPoly, gPoly); |
---|
195 | |
---|
196 | fPoly=(c^4*k^2-5*c^3*f*h*k+4*c^2*e*h*k^2+4*c^2*f^2*h^2-4*c*e*f*h^2*k); |
---|
197 | gPoly=(-c^3*f*k^2+c^2*e*k^3+2*c^2*f^2*h*k-2*c*e*f*h*k^2); |
---|
198 | simplifyGcd(fPoly, gPoly); |
---|
199 | |
---|
200 | fPoly=(-8001*c^4*e*f*k^6+8001*c^4*f^3*h*k^4+8001*c^3*e^2*k^7+8001*c^3*e*f^2*h*k^5+16001*c^3*f^4*h^2*k^3+16001*c^2*e^2*f*h*k^6-16001*c^2*e*f^3*h^2*k^4); |
---|
201 | gPoly=(16001*c^7*e*h*k^3-15998*c^6*e*f*h^2*k^2-7*c^5*e*f^2*h^3*k-8*c^4*e^2*f*h^3*k^2+4*c^4*e*f^3*h^4+8*c^3*e^3*h^3*k^3+24*c^3*e^2*f^2*h^4*k-24*c^2*e^3*f*h^4*k^2-16*c^2*e^2*f^3*h^5+16*c*e^3*f^2*h^5*k); |
---|
202 | simplifyGcd(fPoly, gPoly); |
---|
203 | tst_status(1);$ |
---|