source: git/Singular/test.cc @ ba5e9e

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