source: git/Tst/Long/std_l.tst @ 341696

spielwiese
Last change on this file since 341696 was 341696, checked in by Hans Schönemann <hannes@…>, 14 years ago
Adding Id property to all files git-svn-id: file:///usr/local/Singular/svn/trunk@12231 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 5.5 KB
Line 
1// $Id$
2
3// std_l.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 / 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  int t1 = timer;
228  def id_res = std(#[1]);
229  t1 = timer - t1;
230  int i;
231  def id_poly = id_res[1];
232  for (i=1; i<=size(id_res); i++)
233  {
234    id_poly = id_poly + id_res[i];
235    if (size(id_res[i]) > 2)
236    {   
237      lead(id_res[i]), lead(id_res[i] - lead(id_res[i])), size(id_res[i]);
238    }
239    else
240    {
241      id_res[i];
242    }
243  }
244  id_poly;
245  tst_ignore(t1, "time");
246  tst_ignore(memory(1), "memory");
247}
248
249proc gencopy
250{
251  def id = #[1];
252  int n = #[2];
253  int i, j;
254  module m;
255 
256 
257  for (i=1; i<=size(id); i++)
258  {
259    m[i] = id[i];
260    for (j=1; j<=n; j++)
261    {
262      m[i] = m[i] + gen(j) *  id[i];
263    }
264  }
265  return (m);
266}
267 
268
269proc std_extended_range(int from, int to, int charac, list orderings)
270{
271  int k, j;
272  list olist = orderings;
273  global_char = charac;
274
275  for (k=from; k<=to; k++)
276  {
277    olist = extend_orderings(orderings, k);
278    for (j=1; j <= size(olist); j++)
279    {
280      global_ordering = olist[j];
281      def id = gcyclic(k, 3, "r");
282      mystd(id);
283      mystd(gencopy(id, 2));
284      kill basering;
285
286      if (k>1)
287      {
288        def id = gcyclic(k-1, 3, "h");
289        mystd(id);
290        mystd(gencopy(id, 2));
291        kill basering;
292      }
293    }
294  }
295}
296
297proc std_range(int from, int to, int charac, list orderings)
298{
299  int k, j;
300  list olist = orderings;
301  global_char = charac;
302 
303  for (k=from; k<=to; k++)
304  {
305    for (j=1; j <= size(olist); j++)
306    {
307      global_ordering = olist[j];
308      def id = gcyclic(k, 3, "r");
309      mystd(id);
310      kill basering;
311
312      if (k>1)
313      {
314        def id = gcyclic(k-1, 3, "h");
315        mystd(id);
316        kill basering;
317      }
318    }
319  }
320}
321
322int global_char = 32003;
323string global_ordering = "dp";
324
325option(prot);
326option(noredefine);
327
328list global_orderings = "dp", "lp", "Dp", "ls", "ds", "Ds";
329
330
331std_extended_range(2, 6, 32003, global_orderings);
332 
333std_extended_range(7, 9, 32003, list("dp"));
334 
335std_range(10,15, 32003, list("dp"));
336
337std_range(2,6, 0, global_orderings);
338
339std_range(7,12, 0,list("dp"));
340tst_status(1);$
Note: See TracBrowser for help on using the repository browser.