source: git/Tst/Short/std_s.tst @ 4e59df4

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