source: git/Singular/test.cc @ c90500

spielwiese
Last change on this file since c90500 was 17228e, checked in by Hans Schoenemann <hannes@…>, 12 years ago
fix: make check (for non-dbug version) removed: static.h
  • 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/Poly.h> // Too old?
152// #include <kernel/PowerSeries.h> // Too old?
153
154#include <kernel/preimage.h>
155
156#include <kernel/nc.h>
157
158#include <kernel/ratgring.h>
159#include <kernel/ringgb.h>
160#include <kernel/semic.h>
161#include <kernel/shiftgb.h>
162
163#include <kernel/spectrum.h>
164#include <kernel/splist.h>
165#include <kernel/stairc.h>
166#include <kernel/structs.h>
167#include <kernel/syz.h>
168// #include <kernel/testpoly.h> // Too old?
169
170#include <kernel/tgbgauss.h>
171#include <kernel/tgb.h>
172
173#include <kernel/timer.h>
174
175#include <kernel/units.h>
176#include <kernel/walkMain.h>
177#include <kernel/walkProc.h>
178#include <kernel/walkSupport.h>
179
180
181// #include <polys/clapconv.h> // due to factory? :(
182// #include <kernel/tgb_internal.h> // :(
183// #include <kernel/F4.h> // uses tgb_internal // :(
184// #include <kernel/IIntvec.h> // :(
185
186
187
188// headers in Singular/
189#include "attrib.h"
190#include "bigintm.h"
191#include "blackbox.h"
192#include "Cache.h"
193#include "CacheImplementation.h"
194#include "cntrlc.h"
195#include "links/dbm_sl.h"
196#include "distrib.h"
197#include "eigenval_ip.h"
198#include "gms.h"
199#include "grammar.h"
200#include "interpolation.h"
201#include "ipconv.h"
202#include "ipid.h"
203#include "ipprint.h"
204#include "ipshell.h"
205#include "janet.h"
206#include "libparse.h"
207#include "lists.h"
208#include "locals.h"
209#include "maps_ip.h"
210#include "Minor.h"
211#include "MinorInterface.h"
212#include "MinorProcessor.h"
213#include "minpoly.h"
214#include "misc_ip.h"
215#include "links/ndbm.h"
216#include "newstruct.h"
217#include "omSingularConfig.h"
218#include "pcv.h"
219#include "links/pipeLink.h"
220#include "run.h"
221#include "sdb.h"
222#include "silink.h"
223#include "links/sing_dbm.h"
224#include "sing_win.h"
225#include "slInit.h"
226#include "links/ssiLink.h"
227#include "stype.h"
228#include "subexpr.h"
229#include "table.h"
230#include "tok.h"
231#include "utils.h"
232#include "walk.h"
233
234#include "fegetopt.h"
235
236void siInit(char *);
237
238int main( int, char *argv[] )
239{
240  // init path names etc.
241//  feInitResources(argv[0]); //???
242  siInit(argv[0]); // ?
243
244  // Libpolys tests:
245
246  // construct the ring Z/32003[x,y,z]
247  // the variable names
248  char **n=(char**)omalloc(3*sizeof(char*));
249  n[0]=omStrDup("x");
250  n[1]=omStrDup("y");
251  n[2]=omStrDup("z2");
252
253
254/*
255  StringSetS("ressources in use (as reported by feStringAppendResources(0):\n");
256  feStringAppendResources(0);
257  PrintS(StringAppendS("\n"));
258
259
260
261  ring R=rDefault(32003,3,n);
262  // make R the default ring:
263  rChangeCurrRing(R);
264
265  // create the polynomial 1
266  poly p1=pISet(1);
267
268  // create tthe polynomial 2*x^3*z^2
269  poly p2=p_ISet(2,R);
270  pSetExp(p2,1,3);
271  pSetExp(p2,3,2);
272  pSetm(p2);
273
274  // print p1 + p2
275  pWrite(p1); printf(" + \n"); pWrite(p2); printf("\n");
276
277  // compute p1+p2
278  p1=p_Add_q(p1,p2,R); p2=NULL;
279  pWrite(p1);
280
281  // clean up:
282  pDelete(&p1);
283
284  rDelete(R);
285  rChangeCurrRing(NULL);
286
287*/
288
289
290
291  currentVoice=feInitStdin(NULL);
292
293  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);
294
295  printf("interpreter returns %d\n",err);
296  if (err)
297     errorreported = 0; // reset error handling
298
299  assume( err == 0 );
300
301
302
303  // hook for error handling:
304  // WerrorS_callback=......; of type p(const char *)
305  err=iiEStart(omStrDup("int ver=system(\"version\");export ver;return();\n"),NULL);
306
307  printf("interpreter returns %d\n",err);
308  if (err)
309     errorreported = 0; // reset error handling
310
311  assume( err == 0 );
312
313  idhdl h=ggetid("ver");
314
315  if (h != NULL)
316    printf("singular variable ver of type %d contains %d\n",h->typ,(int)(long)IDDATA(h));
317  else
318    printf("variable ver does not exist\n");
319
320  assume( h != NULL );
321
322
323  err = iiEStart(
324                 omStrDup("system(\"--version\");return();\n"),
325                 NULL);
326
327  printf("interpreter returns %d\n",err);
328  if (err)
329     errorreported = 0; // reset error handling
330
331  assume( err == 0 );
332
333  // calling a singular-library function
334  idhdl datetime=ggetid("datetime");
335  if (datetime==NULL)
336    printf("datetime not found\n");
337  else
338  {
339    leftv res=iiMake_proc(datetime,NULL,NULL);
340    if (res==NULL) { printf("datetime return an error\n"); errorreported = 0; }
341    else           printf("datetime returned type %d, >>%s<<\n",res->Typ(),(char *)res->Data());
342  }
343
344  // changing a ring for the interpreter
345  // re-using n and R from above
346  ring R = rDefault(32003, 3, n);
347  idhdl newRingHdl=enterid("R" /* ring name*/,
348                           0, /*nesting level, 0=global*/
349                           RING_CMD,
350                           &IDROOT,
351                           FALSE);
352
353  IDRING(newRingHdl)=R;
354  // make R the default ring (include rChangeCurrRing):
355  rSetHdl(newRingHdl);
356  err=iiEStart(omStrDup("R; system(\"r\", R); poly p=x; p; system(\"p\", p); \"\"; poly pp = p * p; pp; listvar(); return();\n"),NULL);
357
358  // calling a kernel function via the interpreter interface
359  sleftv r1; memset(&r1,0,sizeof(r1));
360  sleftv arg; memset(&arg,0,sizeof(r1));
361  arg.rtyp=STRING_CMD;
362  arg.data=omStrDup("huhu");
363  err=iiExprArith1(&r1,&arg,TYPEOF_CMD);
364
365  printf("interpreter returns %d\n",err);
366  if (err)
367     errorreported = 0; // reset error handling
368  else
369     printf("typeof returned type %d, >>%s<<\n",r1.Typ(),r1.Data());
370
371  // clean up r1:
372  r1.CleanUp();
373
374  return 0;
375}
376
Note: See TracBrowser for help on using the repository browser.