source: git/Tst/Long/std_l.tst @ 0bc5ed4

spielwiese
Last change on this file since 0bc5ed4 was ef52d6, checked in by Oleksandr Motsak <motsak@…>, 11 years ago
Update testsuite wrt current master (320c4f5e64cad778b4ada9556a9b0a6c71cab83a) NOTE: some wrong/bad tests were removed... TODO: add the reset of these updates after updating LIB/
  • Property mode set to 100644
File size: 5.5 KB
Line 
1// std_l.tst -- long tests for std
2// uses rcyclic examples from ISSAC'98 paper
3
4LIB "tst.lib";
5tst_init();
6
7proc 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
14proc 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 
33proc 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
59proc 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
72proc 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
151proc 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
163proc 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
223proc mystd
224{
225  int t1 = timer;
226  def id_res = std(#[1]);
227  t1 = timer - t1;
228  int i;
229  def id_poly = id_res[1];
230  for (i=1; i<=size(id_res); i++)
231  {
232    id_poly = id_poly + id_res[i];
233    if (size(id_res[i]) > 2)
234    {   
235      lead(id_res[i]), lead(id_res[i] - lead(id_res[i])), size(id_res[i]);
236    }
237    else
238    {
239      id_res[i];
240    }
241  }
242  id_poly;
243  tst_ignore(t1, "time");
244  tst_ignore(memory(1), "memory");
245}
246
247proc gencopy
248{
249  def id = #[1];
250  int n = #[2];
251  int i, j;
252  module m;
253 
254 
255  for (i=1; i<=size(id); i++)
256  {
257    m[i] = id[i];
258    for (j=1; j<=n; j++)
259    {
260      m[i] = m[i] + gen(j) *  id[i];
261    }
262  }
263  return (m);
264}
265 
266
267proc std_extended_range(int from, int to, int charac, list orderings)
268{
269  int k, j;
270  list olist = orderings;
271  global_char = charac;
272
273  for (k=from; k<=to; k++)
274  {
275    olist = extend_orderings(orderings, k);
276    for (j=1; j <= size(olist); j++)
277    {
278      global_ordering = olist[j];
279      def id = gcyclic(k, 3, "r");
280      mystd(id);
281      mystd(gencopy(id, 2));
282      kill basering;
283
284      if (k>1)
285      {
286        def id = gcyclic(k-1, 3, "h");
287        mystd(id);
288        mystd(gencopy(id, 2));
289        kill basering;
290      }
291    }
292  }
293}
294
295proc std_range(int from, int to, int charac, list orderings)
296{
297  int k, j;
298  list olist = orderings;
299  global_char = charac;
300 
301  for (k=from; k<=to; k++)
302  {
303    for (j=1; j <= size(olist); j++)
304    {
305      global_ordering = olist[j];
306      def id = gcyclic(k, 3, "r");
307      mystd(id);
308      kill basering;
309
310      if (k>1)
311      {
312        def id = gcyclic(k-1, 3, "h");
313        mystd(id);
314        kill basering;
315      }
316    }
317  }
318}
319
320int global_char = 32003;
321string global_ordering = "dp";
322
323//option(prot);
324option(noredefine);
325
326list global_orderings = "dp", "lp", "Dp", "ls", "ds", "Ds";
327
328
329std_extended_range(2, 6, 32003, global_orderings);
330 
331std_extended_range(7, 9, 32003, list("dp"));
332 
333std_range(10,15, 32003, list("dp"));
334
335std_range(2,6, 0, global_orderings);
336
337std_range(7,12, 0,list("dp"));
338tst_status(1);$
Note: See TracBrowser for help on using the repository browser.