source: git/Singular/test.cc @ 3bdd16

fieker-DuValspielwiese
Last change on this file since 3bdd16 was 3bdd16, checked in by Oleksandr Motsak <motsak@…>, 13 years ago
CHG: don't use Pyobjects yet...
  • Property mode set to 100644
File size: 7.9 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
255  StringSetS("ressources in use (as reported by feStringAppendResources(0):\n");
256  feStringAppendResources(0);
257  PrintS(StringAppendS("\n"));
258
259   
260   
261  // Libpolys tests:
262   
263  // construct the ring Z/32003[x,y,z]
264  // the variable names
265  char **n=(char**)omalloc(3*sizeof(char*));
266  n[0]=omStrDup("x");
267  n[1]=omStrDup("y");
268  n[2]=omStrDup("z2");
269
270  ring R=rDefault(32003,3,n);
271  // make R the default ring:
272  rChangeCurrRing(R);
273
274  // create the polynomial 1
275  poly p1=pISet(1);
276
277  // create tthe polynomial 2*x^3*z^2
278  poly p2=p_ISet(2,R);
279  pSetExp(p2,1,3);
280  pSetExp(p2,3,2);
281  pSetm(p2);
282
283  // print p1 + p2
284  pWrite(p1); printf(" + \n"); pWrite(p2); printf("\n");
285
286  // compute p1+p2
287  p1=p_Add_q(p1,p2,R); p2=NULL;
288  pWrite(p1); 
289
290  // clean up:
291  pDelete(&p1);
292   
293  rDelete(R);
294  rChangeCurrRing(NULL);
295   
296
297   
298   
299  currentVoice=feInitStdin(NULL);
300   
301   
302  // hook for error handling:
303  // WerrorS_callback=......; of type p(const char *)
304  int err=iiEStart(omStrDup("int ver=system(\"version\");export ver;return();\n"),NULL);
305  if (err) errorreported = 0; // reset error handling
306  printf("interpreter returns %d\n",err);
307  idhdl h=ggetid("ver");
308  if (h!=NULL)
309    printf("singular variable ver of type %d contains %d\n",h->typ,(int)(long)IDDATA(h));
310  else
311    printf("variable ver does not exist\n");
312
313  // calling a singular-library function
314  idhdl datetime=ggetid("datetime");
315  if (datetime==NULL)
316    printf("datetime not found\n");
317  else
318  {
319    leftv res=iiMake_proc(datetime,NULL,NULL);
320    if (res==NULL) { printf("datetime return an error\n"); errorreported = 0; }
321    else           printf("datetime returned type %d, >>%s<<\n",res->Typ(),(char *)res->Data());
322  }
323
324  // changing a ring for the interpreter
325  // re-using n and R from above
326  R=rDefault(32003,3,n);
327  idhdl newRingHdl=enterid("R" /* ring name*/,
328                           0, /*nesting level, 0=global*/
329                           RING_CMD,
330                           &IDROOT,
331                           FALSE);
332   IDRING(newRingHdl)=R;
333   // make R the default ring (include rChangeCurrRing):
334   rSetHdl(newRingHdl);
335   err=iiEStart(omStrDup("poly p=x;listvar();return();\n"),NULL);
336
337  // calling a kernel function via the interpreter interface
338  sleftv r1; memset(&r1,0,sizeof(r1));
339  sleftv arg; memset(&arg,0,sizeof(r1));
340  arg.rtyp=STRING_CMD;
341  arg.data=omStrDup("huhu");
342  err=iiExprArith1(&r1,&arg,TYPEOF_CMD);
343  printf("interpreter returns %d\n",err);
344  if (err) errorreported = 0; // reset error handling
345  else printf("typeof returned type %d, >>%s<<\n",r1.Typ(),r1.Data());
346  // clean up r1:
347  r1.CleanUp();
348   
349  return 0;
350}
351
Note: See TracBrowser for help on using the repository browser.