source: git/Singular/test.cc @ f5d2647

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