source: git/Singular/test.cc @ e6f615

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