source: git/Singular/test.cc @ 7b8818

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