source: git/Singular/test.cc @ 922890

fieker-DuValspielwiese
Last change on this file since 922890 was 922890, checked in by Hans Schoenemann <hannes@…>, 10 years ago
moved stairc.h to kernel/combinatorics/
  • Property mode set to 100644
File size: 9.1 KB
Line 
1
2
3
4
5#include <kernel/mod2.h>
6
7#include <omalloc/omalloc.h>
8#include <misc/auxiliary.h>
9
10#include <factory/factory.h> // :(
11
12
13#include <misc/intvec.h>
14#include <misc/int64vec.h>
15#include <misc/mylimits.h>
16#include <misc/options.h>
17
18#include <reporter/reporter.h>
19
20#include <resources/feFopen.h>
21#include <resources/feResource.h>
22
23#include <coeffs/coeffs.h>
24
25#include <coeffs/si_gmp.h>
26
27#include <polys/kbuckets.h>
28#include <polys/matpol.h>
29#include <polys/mod_raw.h>
30#include <polys/prCopy.h>
31#include <polys/sbuckets.h>
32#include <polys/simpleideals.h>
33#include <polys/weight.h>
34
35#include <polys/monomials/maps.h>
36#include <polys/monomials/monomials.h>
37#include <polys/monomials/p_polys.h>
38#include <polys/monomials/ring.h>
39
40#include <polys/nc/nc.h>
41#include <polys/nc/ncSACache.h>
42#include <polys/nc/ncSAFormula.h>
43#include <polys/nc/ncSAMult.h>
44#include <polys/nc/sca.h>
45#include <polys/nc/summator.h>
46
47
48#include <polys/templates/p_MemAdd.h>
49#include <polys/templates/p_Procs.h>
50
51#include <polys/operations/pShallowCopyDelete.h>
52
53#include <polys/clapsing.h>
54
55
56#include <coeffs/numbers.h>
57#include <kernel/polys.h>
58
59
60#include <kernel/structs.h>
61
62
63// HEADERS:
64#include <kernel/combinatorics/hutil.h>
65#include <kernel/combinatorics/stairc.h>
66#include <kernel/ideals.h>
67#include <kernel/GBEngine/syz.h>
68#include <kernel/maps/fast_maps.h>
69#include <Singular/fevoices.h>
70#include <kernel/groebner_walk/walkProc.h>
71#include <kernel/groebner_walk/walkMain.h>
72#include <kernel/groebner_walk/walkSupport.h>
73#include <kernel/GBEngine/khstd.h>
74/// #include <kernel/sparsmat.h> // TODO: install polys/this!
75//+
76
77#include <kernel/fglm/fglm.h>
78#include <kernel/GBEngine/kstd1.h>
79#include <kernel/fglm/fglmgauss.h>
80#include <kernel/fglm/fglmvec.h>
81#include <kernel/GBEngine/kstdfac.h>
82#include <kernel/spectrum/kmatrix.h>
83#include <kernel/spectrum/GMPrat.h>
84#include <kernel/spectrum/multicnt.h>
85#include <kernel/spectrum/npolygon.h>
86#include <kernel/spectrum/semic.h>
87#include <kernel/spectrum/spectrum.h>
88#include <kernel/spectrum/splist.h>
89#include <kernel/spectrum/multicnt.h>
90#include <kernel/linear_algebra/eigenval.h>
91#include <kernel/GBEngine/units.h>
92#include <kernel/GBEngine/ratgring.h>
93#include <kernel/GBEngine/shiftgb.h>
94
95#include <kernel/GBEngine/kutil.h>
96
97// #include <kernel/dbm_sl.h> // TODO: needs si_link// already moved to Singular/!
98
99// #include "CCRing.h" // Too old!
100#include <kernel/digitech.h>
101#include <kernel/linear_algebra/eigenval.h>
102#include <kernel/maps/fast_maps.h>
103#include <kernel/fast_mult.h>
104#include <kernel/oswrapper/feread.h>
105
106#include <kernel/fglm/fglmgauss.h>
107#include <kernel/fglm/fglm.h>
108#include <kernel/fglm/fglmvec.h>
109
110////////#include "F5cData.h"
111#include <kernel/GBEngine/f5c.h>
112#include <kernel/GBEngine/f5data.h>
113#include <kernel/GBEngine/f5gb.h>
114#include <kernel/GBEngine/f5lists.h>
115////////#include <kernel/F5cLists.h>
116
117
118#include <kernel/spectrum/GMPrat.h>
119
120// #include "htmlhelp.h" // For Windows //
121#include <kernel/combinatorics/hutil.h>
122// #include <kernel/Ideal.h> // Too old?
123
124
125#include <kernel/ideals.h>
126
127#include <kernel/spectrum/kmatrix.h>
128#include <kernel/GBEngine/kstd1.h>
129#include <kernel/GBEngine/kstdfac.h>
130#include <kernel/GBEngine/khstd.h>
131
132#include <kernel/linear_algebra/linearAlgebra.h>
133
134
135
136// #include "lplist.h" // Too old!
137#include <kernel/spectrum/multicnt.h>
138#include <kernel/spectrum/npolygon.h>
139// #include <kernel/Number.h> // Too old?
140// #include <kernel/Poly.h> // Too old?
141// #include <kernel/PowerSeries.h> // Too old?
142
143#include <kernel/preimage.h>
144
145#include <kernel/GBEngine/nc.h>
146
147#include <kernel/GBEngine/ratgring.h>
148#include <kernel/GBEngine/ringgb.h>
149#include <kernel/spectrum/semic.h>
150#include <kernel/GBEngine/shiftgb.h>
151
152#include <kernel/spectrum/spectrum.h>
153#include <kernel/spectrum/splist.h>
154#include <kernel/structs.h>
155#include <kernel/GBEngine/syz.h>
156// #include <kernel/testpoly.h> // Too old?
157
158#include <kernel/GBEngine/tgbgauss.h>
159#include <kernel/GBEngine/tgb.h>
160
161#include <kernel/oswrapper/timer.h>
162
163#include <kernel/GBEngine/units.h>
164#include <kernel/groebner_walk/walkMain.h>
165#include <kernel/groebner_walk/walkProc.h>
166#include <kernel/groebner_walk/walkSupport.h>
167
168
169// #include <polys/clapconv.h> // due to factory? :(
170// #include <kernel/tgb_internal.h> // :(
171// #include <kernel/F4.h> // uses tgb_internal // :(
172// #include <kernel/IIntvec.h> // :(
173
174
175// headers in Singular/
176#include <Singular/mmalloc.h>
177//#include <Singular/idrec.h> // moved to Singular
178#include <Singular/attrib.h>
179#include <Singular/blackbox.h>
180#include <Singular/cntrlc.h>
181#include <Singular/links/dbm_sl.h>
182#include <Singular/distrib.h>
183#include <Singular/eigenval_ip.h>
184#include <Singular/gms.h>
185#include <Singular/grammar.h>
186#include <Singular/ipconv.h>
187#include <Singular/ipid.h>
188#include <Singular/ipprint.h>
189#include <Singular/ipshell.h>
190#include <Singular/libparse.h>
191#include <Singular/lists.h>
192#include <Singular/locals.h>
193#include <Singular/maps_ip.h>
194#include <Singular/misc_ip.h>
195#include <Singular/links/ndbm.h>
196#include <Singular/newstruct.h>
197#include <Singular/omSingularConfig.h>
198#include <Singular/pcv.h>
199#include <Singular/links/pipeLink.h>
200#include <Singular/run.h>
201#include <Singular/sdb.h>
202#include <Singular/links/silink.h>
203#include <Singular/links/sing_dbm.h>
204#include <Singular/sing_win.h>
205#include <Singular/links/slInit.h>
206#include <Singular/links/ssiLink.h>
207#include <Singular/stype.h>
208#include <Singular/subexpr.h>
209#include <Singular/tok.h>
210#include <Singular/utils.h>
211#include <Singular/walk.h>
212
213#include <Singular/fegetopt.h>
214
215void siInit(char *);
216
217int main( int, char *argv[] )
218{
219  assume( sizeof(long) == SIZEOF_LONG );
220
221  if( sizeof(long) != SIZEOF_LONG )
222  {
223     WerrorS("Bad config.h: wrong size of long!");
224
225     return(1);
226  }
227
228   // init path names etc.
229//  feInitResources(argv[0]); //???
230  siInit(argv[0]); // ?
231
232  if( char *s = versionString() )
233  {
234    PrintS(s);
235    omFree(s);
236  }
237
238
239
240  StringSetS("ressources in use (as reported by feStringAppendResources(0):\n");
241  feStringAppendResources(0);
242  StringAppendS("\n");
243  if( char * s = StringEndS() )
244  {
245    PrintS(s);
246    omFree(s);
247  }
248
249
250
251
252  // Libpolys tests:
253
254  // construct the ring Z/32003[x,y,z]
255  // the variable names
256  char **n=(char**)omalloc(3*sizeof(char*));
257  n[0]=omStrDup("x");
258  n[1]=omStrDup("y");
259  n[2]=omStrDup("z2");
260
261
262
263/*
264  ring R=rDefault(32003,3,n);
265  // make R the default ring:
266  rChangeCurrRing(R);
267
268  // create the polynomial 1
269  poly p1=pISet(1);
270
271  // create tthe polynomial 2*x^3*z^2
272  poly p2=p_ISet(2,R);
273  pSetExp(p2,1,3);
274  pSetExp(p2,3,2);
275  pSetm(p2);
276
277  // print p1 + p2
278  pWrite(p1); printf(" + \n"); pWrite(p2); printf("\n");
279
280  // compute p1+p2
281  p1=p_Add_q(p1,p2,R); p2=NULL;
282  pWrite(p1);
283
284  // clean up:
285  pDelete(&p1);
286
287  rDelete(R);
288  rChangeCurrRing(NULL);
289
290*/
291
292
293
294  currentVoice=feInitStdin(NULL);
295
296  int err=iiEStart(omStrDup("ring R = (0, a), x, dp; R; system(\"r\", R); minpoly=a*a+1; R; system(\"r\", R); kill R; return();\n"),NULL);
297
298  printf("interpreter returns %d\n",err);
299  if (err)
300     errorreported = 0; // reset error handling
301
302  assume( err == 0 );
303
304
305
306  // hook for error handling:
307  // WerrorS_callback=......; of type p(const char *)
308  err=iiEStart(omStrDup("int ver=system(\"version\");export ver;return();\n"),NULL);
309
310  printf("interpreter returns %d\n",err);
311  if (err)
312     errorreported = 0; // reset error handling
313
314  assume( err == 0 );
315
316  idhdl h=ggetid("ver");
317
318  if (h != NULL)
319    printf("singular variable ver of type %d contains %d\n",h->typ,(int)(long)IDDATA(h));
320  else
321    printf("variable ver does not exist\n");
322
323  assume( h != NULL );
324
325
326  err = iiEStart(
327                 omStrDup("system(\"--version\");return();\n"),
328                 NULL);
329
330  printf("interpreter returns %d\n",err);
331  if (err)
332     errorreported = 0; // reset error handling
333
334  assume( err == 0 );
335
336  // calling a singular-library function
337  idhdl datetime=ggetid("datetime");
338  if (datetime==NULL)
339    printf("datetime not found\n");
340  else
341  {
342    const BOOLEAN res=iiMake_proc(datetime,NULL,NULL);
343    if (res)
344    {
345      printf("iiMake_proc: datetime return an error\n");
346      errorreported = 0;
347    }
348    else
349    {
350      printf("iiMake_proc: datetime returned type %d, >>%s<<\n", iiRETURNEXPR.Typ(), (char *)iiRETURNEXPR.Data());
351      iiRETURNEXPR.CleanUp(); // calls Init afterwards
352    }
353  }
354
355  // changing a ring for the interpreter
356  // re-using n and R from above
357  ring R = rDefault(32003, 3, n);
358  idhdl newRingHdl=enterid("R" /* ring name*/,
359                           0, /*nesting level, 0=global*/
360                           RING_CMD,
361                           &IDROOT,
362                           FALSE);
363
364  IDRING(newRingHdl)=R;
365  // make R the default ring (include rChangeCurrRing):
366  rSetHdl(newRingHdl);
367  err=iiEStart(omStrDup("R; system(\"r\", R); poly p=x; p; system(\"p\", p); \"\"; poly pp = p * p; pp; listvar(); return();\n"),NULL);
368
369  // calling a kernel function via the interpreter interface
370  sleftv r1; memset(&r1,0,sizeof(r1));
371  sleftv arg; memset(&arg,0,sizeof(r1));
372  arg.rtyp=STRING_CMD;
373  arg.data=omStrDup("huhu");
374  err=iiExprArith1(&r1,&arg,TYPEOF_CMD);
375
376  printf("interpreter returns %d\n",err);
377  if (err)
378     errorreported = 0; // reset error handling
379  else
380     printf("typeof returned type %d, >>%s<<\n",r1.Typ(),r1.Data());
381
382  // clean up r1:
383  r1.CleanUp();
384
385  return 0;
386}
387
Note: See TracBrowser for help on using the repository browser.