source: git/Singular/test.cc @ 4093f9

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