source: git/Singular/test.cc @ 207e0b

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