source: git/Tst/Short/std_s.tst @ a866f1

spielwiese
Last change on this file since a866f1 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.6 KB
Line 
1// std_s.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  "(" + 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
250proc 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
270proc 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
298proc 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
323int global_char = 32003;
324string global_ordering = "dp";
325
326option(prot);
327option(noredefine);
328
329list global_orderings = "dp", "lp";
330
331std_extended_range(2, 5, 32003, global_orderings);
332
333std_range(6,10, 32003, list("dp"));
334
335std_range(2,5, 0, global_orderings);
336
337std_range(6,10, 0,list("dp"));
338tst_status(1);$
339LIB "poly.lib";
340killall();
341killall("proc");
342exit;
Note: See TracBrowser for help on using the repository browser.