1 | // std_s.tst -- long tests for std |
---|
2 | // uses rcyclic examples from ISSAC'98 paper |
---|
3 | |
---|
4 | LIB "tst.lib"; |
---|
5 | tst_init(); |
---|
6 | |
---|
7 | proc msetring(int charac, int nv, string ordering) |
---|
8 | { |
---|
9 | execute("ring r = " + string(charac) + ",x(1.." + string(nv) + "), " + |
---|
10 | ordering + ";"); |
---|
11 | keepring r; |
---|
12 | } |
---|
13 | |
---|
14 | proc ecyclic_i(int i, int comps) |
---|
15 | { |
---|
16 | int j, k, l; |
---|
17 | poly p, q; |
---|
18 | |
---|
19 | for (j=1; j<=comps; j++) |
---|
20 | { |
---|
21 | q = 1; |
---|
22 | l = j; |
---|
23 | for (k=1; k<=i; k++) |
---|
24 | { |
---|
25 | q = q *var(l); |
---|
26 | l = l + comps; |
---|
27 | } |
---|
28 | p = p + q; |
---|
29 | } |
---|
30 | return (p); |
---|
31 | } |
---|
32 | |
---|
33 | proc rcyclic_i(int i, int vars, int comps) |
---|
34 | { |
---|
35 | int j, k, l; |
---|
36 | poly p, q; |
---|
37 | |
---|
38 | for (j=1; j<=comps; j++) |
---|
39 | { |
---|
40 | q = 1; |
---|
41 | l = j; |
---|
42 | for (k=1; k<=i; k++) |
---|
43 | { |
---|
44 | q = q *var(l); |
---|
45 | if (l == vars) |
---|
46 | { |
---|
47 | l = 1; |
---|
48 | } |
---|
49 | else |
---|
50 | { |
---|
51 | l = l + 1; |
---|
52 | } |
---|
53 | } |
---|
54 | p = p + q; |
---|
55 | } |
---|
56 | return (p); |
---|
57 | } |
---|
58 | |
---|
59 | proc rcyclic_g(int vars, int comps) |
---|
60 | { |
---|
61 | ideal id; |
---|
62 | int i; |
---|
63 | |
---|
64 | for (i=1; i<vars; i++) |
---|
65 | { |
---|
66 | id[i] = rcyclic_i(i, vars, comps); |
---|
67 | } |
---|
68 | |
---|
69 | return (id); |
---|
70 | } |
---|
71 | |
---|
72 | proc gcyclic(int vars, list #) |
---|
73 | { |
---|
74 | if (vars < 1) |
---|
75 | { |
---|
76 | vars = 2; |
---|
77 | } |
---|
78 | int comps = vars; |
---|
79 | string kind = "n"; |
---|
80 | |
---|
81 | if (size(#) > 0) |
---|
82 | { |
---|
83 | if (typeof(#[1]) == "string") |
---|
84 | { |
---|
85 | if (#[1] == "r" || #[1] == "h") |
---|
86 | { |
---|
87 | kind = #[1]; |
---|
88 | } |
---|
89 | if (size(#) > 1) |
---|
90 | { |
---|
91 | if (typeof(#[2]) == "int" && #[2] > 1 && #[2] < vars) |
---|
92 | { |
---|
93 | comps = #[2]; |
---|
94 | } |
---|
95 | } |
---|
96 | } |
---|
97 | else |
---|
98 | { |
---|
99 | if (typeof(#[1]) == "int") |
---|
100 | { |
---|
101 | if (#[1] > 1 && #[1] < vars) |
---|
102 | { |
---|
103 | comps = #[1]; |
---|
104 | } |
---|
105 | if (size(#) > 1) |
---|
106 | { |
---|
107 | if (#[2] == "r" || #[2] == "h") |
---|
108 | { |
---|
109 | kind = #[2]; |
---|
110 | } |
---|
111 | } |
---|
112 | } |
---|
113 | } |
---|
114 | } |
---|
115 | |
---|
116 | if (kind != "h") |
---|
117 | { |
---|
118 | msetring(global_char, vars, global_ordering); |
---|
119 | } |
---|
120 | else |
---|
121 | { |
---|
122 | msetring(global_char, vars+1, global_ordering); |
---|
123 | } |
---|
124 | |
---|
125 | keepring basering; |
---|
126 | |
---|
127 | ideal id = rcyclic_g(vars, comps); |
---|
128 | poly p = 1; |
---|
129 | int i; |
---|
130 | |
---|
131 | if (kind == "h" || kind == "n") |
---|
132 | { |
---|
133 | for (i=1; i<=vars; i++) |
---|
134 | { |
---|
135 | p = p * var(i); |
---|
136 | } |
---|
137 | id[vars] = p; |
---|
138 | if (kind == "h") |
---|
139 | { |
---|
140 | id[vars] = id[vars] - var(vars+1)^vars; |
---|
141 | } |
---|
142 | else |
---|
143 | { |
---|
144 | id[vars] = id[vars] -1; |
---|
145 | } |
---|
146 | } |
---|
147 | |
---|
148 | return (id); |
---|
149 | } |
---|
150 | |
---|
151 | proc generate_weight_str(int j) |
---|
152 | { |
---|
153 | int i; |
---|
154 | string res_str = "("; |
---|
155 | |
---|
156 | for (i=1; i<j; i++) |
---|
157 | { |
---|
158 | res_str = res_str + string(i) + ","; |
---|
159 | } |
---|
160 | return (res_str + string(j) + ")"); |
---|
161 | } |
---|
162 | |
---|
163 | proc extend_orderings(list olist, int j) |
---|
164 | { |
---|
165 | int i; |
---|
166 | int c1; |
---|
167 | int c2; |
---|
168 | string o1; |
---|
169 | string o2; |
---|
170 | string o3; |
---|
171 | list nl; |
---|
172 | string weight_string = generate_weight_str(j); |
---|
173 | o1 = olist[1]; |
---|
174 | if (size(olist) > 1) |
---|
175 | { |
---|
176 | o2 = olist[2]; |
---|
177 | if (size(olist) > 2) |
---|
178 | { |
---|
179 | o3 = olist[3]; |
---|
180 | } |
---|
181 | else |
---|
182 | { |
---|
183 | o3 = olist[2]; |
---|
184 | } |
---|
185 | } |
---|
186 | else |
---|
187 | { |
---|
188 | o2 = o1; |
---|
189 | o3 = o1; |
---|
190 | } |
---|
191 | |
---|
192 | // add weight orderings |
---|
193 | olist = olist + list("Wp" + weight_string, "wp" + weight_string); |
---|
194 | |
---|
195 | |
---|
196 | for (i=1; i<=size(olist); i++) |
---|
197 | { |
---|
198 | nl = nl + list(olist[i], "(C," + olist[i] + ")", "(c," + olist[i] + ")", |
---|
199 | "(" + olist[i] + ",C)", "(" + olist[i] + ",c)"); |
---|
200 | } |
---|
201 | |
---|
202 | // add product orderings |
---|
203 | if (j > 1) |
---|
204 | { |
---|
205 | c1 = j div 2; |
---|
206 | if (c1 + c1 == j) |
---|
207 | { |
---|
208 | c2 = c1; |
---|
209 | } |
---|
210 | else |
---|
211 | { |
---|
212 | c2 = c1 + 1; |
---|
213 | } |
---|
214 | nl = nl + list("(" + o1 + "(" + string(c1) + "),"+ o2 + "(" + string(c2) + "))", "(" + o1 + "(" + string(c1) + "),"+ o3 + "(" + string(c2) + "))"); |
---|
215 | // and, extra weight vector |
---|
216 | nl = nl + list("(a" + weight_string + "," + o2 + "(" + string(c1) + "),"+ o3 + "(" + string(c2) + "))", "(a" + generate_weight_str(j-1)+ "," + o3 + "(" + string(c1) + "),"+ o1 + "(" + string(c2) + "))"); |
---|
217 | } |
---|
218 | |
---|
219 | return (nl); |
---|
220 | |
---|
221 | } |
---|
222 | |
---|
223 | proc mystd |
---|
224 | { |
---|
225 | "(" + charstr(basering) + "),(" + varstr(basering) + "),(" + ordstr(basering) + ");"; |
---|
226 | print(#[1]); |
---|
227 | int t1 = timer; |
---|
228 | def id_res = std(#[1]); |
---|
229 | id_res; |
---|
230 | // t1 = timer - t1; |
---|
231 | // int i; |
---|
232 | // def id_poly = id_res[1]; |
---|
233 | // for (i=1; i<=size(id_res); i++) |
---|
234 | // { |
---|
235 | // id_poly = id_poly + id_res[i]; |
---|
236 | // if (size(id_res[i]) > 2) |
---|
237 | // { |
---|
238 | // lead(id_res[i]), lead(id_res[i] - lead(id_res[i])), size(id_res[i]); |
---|
239 | // } |
---|
240 | // else |
---|
241 | // { |
---|
242 | // id_res[i]; |
---|
243 | // } |
---|
244 | // } |
---|
245 | // id_poly; |
---|
246 | // tst_ignore(t1, "time"); |
---|
247 | // tst_ignore(memory(1), "memory"); |
---|
248 | } |
---|
249 | |
---|
250 | proc gencopy |
---|
251 | { |
---|
252 | def id = #[1]; |
---|
253 | int n = #[2]; |
---|
254 | int i, j; |
---|
255 | module m; |
---|
256 | |
---|
257 | |
---|
258 | for (i=1; i<=size(id); i++) |
---|
259 | { |
---|
260 | m[i] = id[i]; |
---|
261 | for (j=1; j<=n; j++) |
---|
262 | { |
---|
263 | m[i] = m[i] + gen(j) * id[i]; |
---|
264 | } |
---|
265 | } |
---|
266 | return (m); |
---|
267 | } |
---|
268 | |
---|
269 | |
---|
270 | proc std_extended_range(int from, int to, int charac, list orderings) |
---|
271 | { |
---|
272 | int k, j; |
---|
273 | list olist = orderings; |
---|
274 | global_char = charac; |
---|
275 | |
---|
276 | for (k=from; k<=to; k++) |
---|
277 | { |
---|
278 | olist = extend_orderings(orderings, k); |
---|
279 | for (j=1; j <= size(olist); j++) |
---|
280 | { |
---|
281 | global_ordering = olist[j]; |
---|
282 | def id = gcyclic(k, 3, "r"); |
---|
283 | mystd(id); |
---|
284 | mystd(gencopy(id, 2)); |
---|
285 | kill basering; |
---|
286 | |
---|
287 | if (k>1) |
---|
288 | { |
---|
289 | def id = gcyclic(k-1, 3, "h"); |
---|
290 | mystd(id); |
---|
291 | mystd(gencopy(id, 2)); |
---|
292 | kill basering; |
---|
293 | } |
---|
294 | } |
---|
295 | } |
---|
296 | } |
---|
297 | |
---|
298 | proc std_range(int from, int to, int charac, list orderings) |
---|
299 | { |
---|
300 | int k, j; |
---|
301 | list olist = orderings; |
---|
302 | global_char = charac; |
---|
303 | |
---|
304 | for (k=from; k<=to; k++) |
---|
305 | { |
---|
306 | for (j=1; j <= size(olist); j++) |
---|
307 | { |
---|
308 | global_ordering = olist[j]; |
---|
309 | def id = gcyclic(k, 3, "r"); |
---|
310 | mystd(id); |
---|
311 | kill basering; |
---|
312 | |
---|
313 | if (k>1) |
---|
314 | { |
---|
315 | def id = gcyclic(k-1, 3, "h"); |
---|
316 | mystd(id); |
---|
317 | kill basering; |
---|
318 | } |
---|
319 | } |
---|
320 | } |
---|
321 | } |
---|
322 | |
---|
323 | int global_char = 32003; |
---|
324 | string global_ordering = "dp"; |
---|
325 | |
---|
326 | option(prot); |
---|
327 | option(noredefine); |
---|
328 | |
---|
329 | list global_orderings = "dp", "lp"; |
---|
330 | |
---|
331 | std_extended_range(2, 5, 32003, global_orderings); |
---|
332 | |
---|
333 | std_range(6,10, 32003, list("dp")); |
---|
334 | |
---|
335 | std_range(2,5, 0, global_orderings); |
---|
336 | |
---|
337 | std_range(6,10, 0,list("dp")); |
---|
338 | tst_status(1);$ |
---|
339 | LIB "poly.lib"; |
---|
340 | killall(); |
---|
341 | killall("proc"); |
---|
342 | exit; |
---|