misc_ip.cc
Go to the documentation of this file.
1 /*****************************************************************************\
2  * Computer Algebra System SINGULAR
3 \*****************************************************************************/
4 /** @file misc_ip.cc
5  *
6  * This file provides miscellaneous functionality.
7  *
8  * For more general information, see the documentation in misc_ip.h.
9  *
10  **/
11 /*****************************************************************************/
12 
13 // include header files
14 #define PLURAL_INTERNAL_DECLARATIONS 1
15 
16 #include <kernel/mod2.h>
17 #include <misc/auxiliary.h>
18 #include <misc/sirandom.h>
19 
20 #include <reporter/si_signals.h>
21 
22 #include <factory/factory.h>
23 
24 #include <coeffs/si_gmp.h>
25 #include <coeffs/coeffs.h>
26 #include <coeffs/OPAE.h>
27 #include <coeffs/OPAEQ.h>
28 #include <coeffs/OPAEp.h>
29 #include <coeffs/flintcf_Q.h>
30 #include <coeffs/flintcf_Zn.h>
31 
34 #include <polys/nc/gb_hack.h>
35 
36 #ifdef HAVE_SIMPLEIPC
38 #endif
39 
40 #include "misc_ip.h"
41 #include "ipid.h"
42 #include "feOpt.h"
43 #include "links/silink.h"
44 #include "mod_lib.h"
45 
46 static FORCE_INLINE void number2mpz(number n, mpz_t m){ number2mpz(n, coeffs_BIGINT, m); }
47 static FORCE_INLINE number mpz2number(mpz_t m){ return mpz2number(m, coeffs_BIGINT); }
48 
49 
50 void setListEntry(lists L, int index, mpz_t n)
51 { /* assumes n > 0 */
52  /* try to fit nn into an int: */
53  if (mpz_size1(n)<=1)
54  {
55  int ui=(int)mpz_get_si(n);
56  if ((((ui<<3)>>3)==ui)
57  && (mpz_cmp_si(n,(long)ui)==0))
58  {
59  L->m[index].rtyp = INT_CMD; L->m[index].data = (void*)(long)ui;
60  return;
61  }
62  }
63  number nn = mpz2number(n);
64  L->m[index].rtyp = BIGINT_CMD; L->m[index].data = (void*)nn;
65 }
66 
67 void setListEntry_ui(lists L, int index, unsigned long ui)
68 { /* assumes n > 0 */
69  /* try to fit nn into an int: */
70  int i=(int)ui;
71  if ((((unsigned long)i)==ui) && (((i<<3)>>3)==i))
72  {
73  L->m[index].rtyp = INT_CMD; L->m[index].data = (void*)(long)i;
74  }
75  else
76  {
77  number nn = n_Init(ui, coeffs_BIGINT);
78  L->m[index].rtyp = BIGINT_CMD; L->m[index].data = (void*)nn;
79  }
80 }
81 
82 /* Factoring with Pollard's rho method. stolen from GMP/demos */
83 static unsigned add[] = {4, 2, 4, 2, 4, 6, 2, 6};
84 
85 static int factor_using_division (mpz_t t, unsigned int limit,lists primes, int *multiplicities,int &index, unsigned long bound)
86 {
87  mpz_t q, r;
88  unsigned long int f;
89  int ai;
90  unsigned *addv = add;
91  unsigned int failures;
92  int bound_not_reached=1;
93 
94  mpz_init (q);
95  mpz_init (r);
96 
97  f = mpz_scan1 (t, 0);
98  mpz_div_2exp (t, t, f);
99  if (f>0)
100  {
101  setListEntry_ui(primes, index, 2);
102  multiplicities[index++] = f;
103  }
104 
105  f=0;
106  loop
107  {
108  mpz_tdiv_qr_ui (q, r, t, 3);
109  if (mpz_cmp_ui (r, 0) != 0)
110  break;
111  mpz_set (t, q);
112  f++;
113  }
114  if (f>0)
115  {
116  setListEntry_ui(primes, index, 3);
117  multiplicities[index++] = f;
118  }
119  f=0;
120  loop
121  {
122  mpz_tdiv_qr_ui (q, r, t, 5);
123  if (mpz_cmp_ui (r, 0) != 0)
124  break;
125  mpz_set (t, q);
126  f++;
127  }
128  if (f>0)
129  {
130  setListEntry_ui(primes, index, 5);
131  multiplicities[index++] = f;
132  }
133 
134  failures = 0;
135  f = 7;
136  ai = 0;
137  unsigned long last_f=0;
138  while (mpz_cmp_ui (t, 1) != 0)
139  {
140  mpz_tdiv_qr_ui (q, r, t, f);
141  if (mpz_cmp_ui (r, 0) != 0)
142  {
143  f += addv[ai];
144  if (mpz_cmp_ui (t, f) < 0)
145  break;
146  ai = (ai + 1) & 7;
147  failures++;
148  if (failures > limit)
149  break;
150  if ((bound!=0) && (f>bound))
151  {
152  bound_not_reached=0;
153  break;
154  }
155  }
156  else
157  {
158  mpz_swap (t, q);
159  if (f!=last_f)
160  {
161  setListEntry_ui(primes, index, f);
162  multiplicities[index]++;
163  index++;
164  }
165  else
166  {
167  multiplicities[index-1]++;
168  }
169  last_f=f;
170  failures = 0;
171  }
172  }
173 
174  mpz_clear (q);
175  mpz_clear (r);
176  //printf("bound=%d,f=%d,failures=%d, reached=%d\n",bound,f,failures,bound_not_reached);
177  return bound_not_reached;
178 }
179 
180 static void factor_using_pollard_rho (mpz_t n, unsigned long a, lists primes, int * multiplicities,int &index)
181 {
182  mpz_t x, x1, y, P;
183  mpz_t t1, t2;
184  mpz_t last_f;
185  unsigned long long k, l, i;
186 
187  mpz_init (t1);
188  mpz_init (t2);
189  mpz_init_set_si (last_f, 0);
190  mpz_init_set_si (y, 2);
191  mpz_init_set_si (x, 2);
192  mpz_init_set_si (x1, 2);
193  mpz_init_set_ui (P, 1);
194  k = 1;
195  l = 1;
196 
197  while (mpz_cmp_ui (n, 1) != 0)
198  {
199  loop
200  {
201  do
202  {
203  mpz_mul (t1, x, x);
204  mpz_mod (x, t1, n);
205  mpz_add_ui (x, x, a);
206  mpz_sub (t1, x1, x);
207  mpz_mul (t2, P, t1);
208  mpz_mod (P, t2, n);
209 
210  if (k % 32 == 1)
211  {
212  mpz_gcd (t1, P, n);
213  if (mpz_cmp_ui (t1, 1) != 0)
214  goto factor_found;
215  mpz_set (y, x);
216  }
217  }
218  while (--k != 0);
219 
220  mpz_gcd (t1, P, n);
221  if (mpz_cmp_ui (t1, 1) != 0)
222  goto factor_found;
223 
224  mpz_set (x1, x);
225  k = l;
226  l = 2 * l;
227  for (i = 0; i < k; i++)
228  {
229  mpz_mul (t1, x, x);
230  mpz_mod (x, t1, n);
231  mpz_add_ui (x, x, a);
232  }
233  mpz_set (y, x);
234  }
235 
236  factor_found:
237  do
238  {
239  mpz_mul (t1, y, y);
240  mpz_mod (y, t1, n);
241  mpz_add_ui (y, y, a);
242  mpz_sub (t1, x1, y);
243  mpz_gcd (t1, t1, n);
244  }
245  while (mpz_cmp_ui (t1, 1) == 0);
246 
247  mpz_divexact (n, n, t1); /* divide by t1, before t1 is overwritten */
248 
249  if (!mpz_probab_prime_p (t1, 10))
250  {
251  do
252  {
253  mp_limb_t a_limb;
254  mpn_random (&a_limb, (mp_size_t) 1);
255  a = a_limb;
256  }
257  while (a == 0);
258 
259  factor_using_pollard_rho (t1, a, primes,multiplicities,index);
260  }
261  else
262  {
263  if (mpz_cmp(t1,last_f)==0)
264  {
265  multiplicities[index-1]++;
266  }
267  else
268  {
269  mpz_set(last_f,t1);
270  setListEntry(primes, index, t1);
271  multiplicities[index++] = 1;
272  }
273  }
274  mpz_mod (x, x, n);
275  mpz_mod (x1, x1, n);
276  mpz_mod (y, y, n);
277  if (mpz_probab_prime_p (n, 10))
278  {
279  if (mpz_cmp(n,last_f)==0)
280  {
281  multiplicities[index-1]++;
282  }
283  else
284  {
285  mpz_set(last_f,n);
286  setListEntry(primes, index, n);
287  multiplicities[index++] = 1;
288  }
289  mpz_set_ui(n,1);
290  break;
291  }
292  }
293 
294  mpz_clear (P);
295  mpz_clear (t2);
296  mpz_clear (t1);
297  mpz_clear (x1);
298  mpz_clear (x);
299  mpz_clear (y);
300  mpz_clear (last_f);
301 }
302 
303 static void factor_gmp (mpz_t t,lists primes,int *multiplicities,int &index,unsigned long bound)
304 {
305  unsigned int division_limit;
306 
307  if (mpz_sgn (t) == 0)
308  return;
309 
310  /* Set the trial division limit according the size of t. */
311  division_limit = mpz_sizeinbase (t, 2);
312  if (division_limit > 1000)
313  division_limit = 1000 * 1000;
314  else
315  division_limit = division_limit * division_limit;
316 
317  if (factor_using_division (t, division_limit,primes,multiplicities,index,bound))
318  {
319  if (mpz_cmp_ui (t, 1) != 0)
320  {
321  if (mpz_probab_prime_p (t, 10))
322  {
323  setListEntry(primes, index, t);
324  multiplicities[index++] = 1;
325  mpz_set_ui(t,1);
326  }
327  else
328  factor_using_pollard_rho (t, 1L, primes,multiplicities,index);
329  }
330  }
331 }
332 /* n and pBound are assumed to be bigint numbers */
333 lists primeFactorisation(const number n, const int pBound)
334 {
335  int i;
336  int index=0;
337  mpz_t nn; number2mpz(n, nn);
338  lists primes = (lists)omAllocBin(slists_bin); primes->Init(1000);
339  int* multiplicities = (int*)omAlloc0(1000*sizeof(int));
340  int positive=1;
341 
342  if (!n_IsZero(n, coeffs_BIGINT))
343  {
344  if (!n_GreaterZero(n, coeffs_BIGINT))
345  {
346  positive=-1;
347  mpz_neg(nn,nn);
348  }
349  factor_gmp(nn,primes,multiplicities,index,pBound);
350  }
351 
352  lists primesL = (lists)omAllocBin(slists_bin);
353  primesL->Init(index);
354  for (i = 0; i < index; i++)
355  {
356  primesL->m[i].rtyp = primes->m[i].rtyp;
357  primesL->m[i].data = primes->m[i].data;
358  primes->m[i].rtyp=0;
359  primes->m[i].data=NULL;
360  }
361  primes->Clean(NULL);
362 
363  lists multiplicitiesL = (lists)omAllocBin(slists_bin);
364  multiplicitiesL->Init(index);
365  for (i = 0; i < index; i++)
366  {
367  multiplicitiesL->m[i].rtyp = INT_CMD;
368  multiplicitiesL->m[i].data = (void*)(long)multiplicities[i];
369  }
370  omFree(multiplicities);
371 
373  L->Init(3);
374  if (positive==-1) mpz_neg(nn,nn);
375  L->m[0].rtyp = LIST_CMD; L->m[0].data = (void*)primesL;
376  L->m[1].rtyp = LIST_CMD; L->m[1].data = (void*)multiplicitiesL;
377  setListEntry(L, 2, nn);
378 
379  mpz_clear(nn);
380 
381  return L;
382 }
383 
384 #include <omalloc/omalloc.h>
385 #include <misc/mylimits.h>
386 
387 #include <misc/options.h>
388 #include <misc/intvec.h>
389 
390 #include <polys/monomials/ring.h>
391 #include <polys/templates/p_Procs.h>
392 
393 #include <kernel/GBEngine/kstd1.h>
394 #include <kernel/oswrapper/timer.h>
395 #include <resources/feResource.h>
396 #include <kernel/oswrapper/feread.h>
397 
398 #include "subexpr.h"
399 #include "cntrlc.h"
400 #include "ipid.h"
401 #include "ipshell.h"
402 
403 #include "fehelp.h"
404 
405 #ifdef HAVE_STATIC
406 #undef HAVE_DYN_RL
407 #endif
408 
409 //#ifdef HAVE_LIBPARSER
410 //# include "libparse.h"
411 //#endif /* HAVE_LIBPARSER */
412 
413 
414 /*2
415 * the renice routine for very large jobs
416 * works only on unix machines,
417 * testet on : linux, HP 9.0
418 *
419 *#include <sys/times.h>
420 *#include <sys/resource.h>
421 *extern "C" int setpriority(int,int,int);
422 *void very_nice()
423 *{
424 *#ifndef NO_SETPRIORITY
425 * setpriority(PRIO_PROCESS,0,19);
426 *#endif
427 * sleep(10);
428 *}
429 */
430 
431 #include <string.h>
432 #include <unistd.h>
433 #include <stdio.h>
434 #include <stddef.h>
435 #include <stdlib.h>
436 #include <time.h>
437 
438 
439 void singular_example(char *str)
440 {
441  assume(str!=NULL);
442  char *s=str;
443  while (*s==' ') s++;
444  char *ss=s;
445  while (*ss!='\0') ss++;
446  while (*ss<=' ')
447  {
448  *ss='\0';
449  ss--;
450  }
451  idhdl h=IDROOT->get(s,myynest);
452  if ((h!=NULL) && (IDTYP(h)==PROC_CMD))
453  {
454  char *lib=iiGetLibName(IDPROC(h));
455  if((lib!=NULL)&&(*lib!='\0'))
456  {
457  Print("// proc %s from lib %s\n",s,lib);
458  s=iiGetLibProcBuffer(IDPROC(h), 2);
459  if (s!=NULL)
460  {
461  if (strlen(s)>5)
462  {
463  iiEStart(s,IDPROC(h));
464  omFree((ADDRESS)s);
465  return;
466  }
467  else omFree((ADDRESS)s);
468  }
469  }
470  }
471  else
472  {
473  char sing_file[MAXPATHLEN];
474  FILE *fd=NULL;
475  char *res_m=feResource('m', 0);
476  if (res_m!=NULL)
477  {
478  sprintf(sing_file, "%s/%s.sing", res_m, s);
479  fd = feFopen(sing_file, "r");
480  }
481  if (fd != NULL)
482  {
483 
484  int old_echo = si_echo;
485  int length, got;
486  char* s;
487 
488  fseek(fd, 0, SEEK_END);
489  length = ftell(fd);
490  fseek(fd, 0, SEEK_SET);
491  s = (char*) omAlloc((length+20)*sizeof(char));
492  got = fread(s, sizeof(char), length, fd);
493  fclose(fd);
494  if (got != length)
495  {
496  Werror("Error while reading file %s", sing_file);
497  }
498  else
499  {
500  s[length] = '\0';
501  strcat(s, "\n;return();\n\n");
502  si_echo = 2;
503  iiEStart(s, NULL);
504  si_echo = old_echo;
505  }
506  omFree(s);
507  }
508  else
509  {
510  Werror("no example for %s", str);
511  }
512  }
513 }
514 
515 
517 {
518  {"prot", Sy_bit(OPT_PROT), ~Sy_bit(OPT_PROT) },
519  {"redSB", Sy_bit(OPT_REDSB), ~Sy_bit(OPT_REDSB) },
520  {"notBuckets", Sy_bit(OPT_NOT_BUCKETS), ~Sy_bit(OPT_NOT_BUCKETS) },
521  {"notSugar", Sy_bit(OPT_NOT_SUGAR), ~Sy_bit(OPT_NOT_SUGAR) },
522  {"interrupt", Sy_bit(OPT_INTERRUPT), ~Sy_bit(OPT_INTERRUPT) },
523  {"sugarCrit", Sy_bit(OPT_SUGARCRIT), ~Sy_bit(OPT_SUGARCRIT) },
524  {"teach", Sy_bit(OPT_DEBUG), ~Sy_bit(OPT_DEBUG) },
525  {"notSyzMinim", Sy_bit(OPT_NO_SYZ_MINIM), ~Sy_bit(OPT_NO_SYZ_MINIM) },
526  /* 9 return SB in syz, quotient, intersect */
527  {"returnSB", Sy_bit(OPT_RETURN_SB), ~Sy_bit(OPT_RETURN_SB) },
528  {"fastHC", Sy_bit(OPT_FASTHC), ~Sy_bit(OPT_FASTHC) },
529  /* 11-19 sort in L/T */
530  {"staircaseBound",Sy_bit(OPT_STAIRCASEBOUND),~Sy_bit(OPT_STAIRCASEBOUND) },
531  {"multBound", Sy_bit(OPT_MULTBOUND), ~Sy_bit(OPT_MULTBOUND) },
532  {"degBound", Sy_bit(OPT_DEGBOUND), ~Sy_bit(OPT_DEGBOUND) },
533  /* 25 no redTail(p)/redTail(s) */
534  {"redTail", Sy_bit(OPT_REDTAIL), ~Sy_bit(OPT_REDTAIL) },
535  {"redThrough", Sy_bit(OPT_REDTHROUGH), ~Sy_bit(OPT_REDTHROUGH) },
536  {"lazy", Sy_bit(OPT_OLDSTD), ~Sy_bit(OPT_OLDSTD) },
537  {"intStrategy", Sy_bit(OPT_INTSTRATEGY), ~Sy_bit(OPT_INTSTRATEGY) },
538  {"infRedTail", Sy_bit(OPT_INFREDTAIL), ~Sy_bit(OPT_INFREDTAIL) },
539  /* 30: use not regularity for syz */
540  {"notRegularity",Sy_bit(OPT_NOTREGULARITY), ~Sy_bit(OPT_NOTREGULARITY) },
541  {"weightM", Sy_bit(OPT_WEIGHTM), ~Sy_bit(OPT_WEIGHTM) },
542 /*special for "none" and also end marker for showOption:*/
543  {"ne", 0, 0 }
544 };
545 
547 {
548  {"mem", Sy_bit(V_SHOW_MEM), ~Sy_bit(V_SHOW_MEM) },
549  {"yacc", Sy_bit(V_YACC), ~Sy_bit(V_YACC) },
550  {"redefine", Sy_bit(V_REDEFINE), ~Sy_bit(V_REDEFINE) },
551  {"reading", Sy_bit(V_READING), ~Sy_bit(V_READING) },
552  {"loadLib", Sy_bit(V_LOAD_LIB), ~Sy_bit(V_LOAD_LIB) },
553  {"debugLib", Sy_bit(V_DEBUG_LIB), ~Sy_bit(V_DEBUG_LIB) },
554  {"loadProc", Sy_bit(V_LOAD_PROC), ~Sy_bit(V_LOAD_PROC) },
555  {"defRes", Sy_bit(V_DEF_RES), ~Sy_bit(V_DEF_RES) },
556  {"usage", Sy_bit(V_SHOW_USE), ~Sy_bit(V_SHOW_USE) },
557  {"Imap", Sy_bit(V_IMAP), ~Sy_bit(V_IMAP) },
558  {"prompt", Sy_bit(V_PROMPT), ~Sy_bit(V_PROMPT) },
559  {"length", Sy_bit(V_LENGTH), ~Sy_bit(V_LENGTH) },
560  {"notWarnSB",Sy_bit(V_NSB), ~Sy_bit(V_NSB) },
561  {"contentSB",Sy_bit(V_CONTENTSB), ~Sy_bit(V_CONTENTSB) },
562  {"cancelunit",Sy_bit(V_CANCELUNIT),~Sy_bit(V_CANCELUNIT)},
563  {"modpsolve",Sy_bit(V_MODPSOLVSB),~Sy_bit(V_MODPSOLVSB)},
564  {"geometricSB",Sy_bit(V_UPTORADICAL),~Sy_bit(V_UPTORADICAL)},
565  {"findMonomials",Sy_bit(V_FINDMONOM),~Sy_bit(V_FINDMONOM)},
566  {"coefStrat",Sy_bit(V_COEFSTRAT), ~Sy_bit(V_COEFSTRAT)},
567  {"qringNF", Sy_bit(V_QRING), ~Sy_bit(V_QRING)},
568  {"warn", Sy_bit(V_ALLWARN), ~Sy_bit(V_ALLWARN)},
569  {"intersectSyz",Sy_bit(V_INTERSECT_SYZ), ~Sy_bit(V_INTERSECT_SYZ)},
570  {"intersectElim",Sy_bit(V_INTERSECT_ELIM), ~Sy_bit(V_INTERSECT_ELIM)},
571 /*special for "none" and also end marker for showOption:*/
572  {"ne", 0, 0 }
573 };
574 
576 {
577  const char *n;
578  do
579  {
580  if (v->Typ()==STRING_CMD)
581  {
582  n=(const char *)v->CopyD(STRING_CMD);
583  }
584  else
585  {
586  if (v->name==NULL)
587  return TRUE;
588  if (v->rtyp==0)
589  {
590  n=v->name;
591  v->name=NULL;
592  }
593  else
594  {
595  n=omStrDup(v->name);
596  }
597  }
598 
599  int i;
600 
601  if(strcmp(n,"get")==0)
602  {
603  intvec *w=new intvec(2);
604  (*w)[0]=si_opt_1;
605  (*w)[1]=si_opt_2;
606  res->rtyp=INTVEC_CMD;
607  res->data=(void *)w;
608  goto okay;
609  }
610  if(strcmp(n,"set")==0)
611  {
612  if((v->next!=NULL)
613  &&(v->next->Typ()==INTVEC_CMD))
614  {
615  v=v->next;
616  intvec *w=(intvec*)v->Data();
617  si_opt_1=(*w)[0];
618  si_opt_2=(*w)[1];
619 #if 0
622 #ifdef HAVE_RINGS
624 #endif
625  ) {
627  }
628 #endif
629  goto okay;
630  }
631  }
632  if(strcmp(n,"none")==0)
633  {
634  si_opt_1=0;
635  si_opt_2=0;
636  goto okay;
637  }
638  for (i=0; (i==0) || (optionStruct[i-1].setval!=0); i++)
639  {
640  if (strcmp(n,optionStruct[i].name)==0)
641  {
642  if (optionStruct[i].setval & validOpts)
643  {
644  si_opt_1 |= optionStruct[i].setval;
645  // optOldStd disables redthrough
646  if (optionStruct[i].setval == Sy_bit(OPT_OLDSTD))
648  }
649  else
650  Warn("cannot set option");
651 #if 0
654 #ifdef HAVE_RINGS
656 #endif
657  ) {
659  }
660 #endif
661  goto okay;
662  }
663  else if ((strncmp(n,"no",2)==0)
664  && (strcmp(n+2,optionStruct[i].name)==0))
665  {
666  if (optionStruct[i].setval & validOpts)
667  {
668  si_opt_1 &= optionStruct[i].resetval;
669  }
670  else
671  Warn("cannot clear option");
672  goto okay;
673  }
674  }
675  for (i=0; (i==0) || (verboseStruct[i-1].setval!=0); i++)
676  {
677  if (strcmp(n,verboseStruct[i].name)==0)
678  {
679  si_opt_2 |= verboseStruct[i].setval;
680  #ifdef YYDEBUG
681  #if YYDEBUG
682  /*debugging the bison grammar --> grammar.cc*/
683  extern int yydebug;
684  if (BVERBOSE(V_YACC)) yydebug=1;
685  else yydebug=0;
686  #endif
687  #endif
688  goto okay;
689  }
690  else if ((strncmp(n,"no",2)==0)
691  && (strcmp(n+2,verboseStruct[i].name)==0))
692  {
693  si_opt_2 &= verboseStruct[i].resetval;
694  #ifdef YYDEBUG
695  #if YYDEBUG
696  /*debugging the bison grammar --> grammar.cc*/
697  extern int yydebug;
698  if (BVERBOSE(V_YACC)) yydebug=1;
699  else yydebug=0;
700  #endif
701  #endif
702  goto okay;
703  }
704  }
705  Werror("unknown option `%s`",n);
706  okay:
707  if (currRing != NULL)
708  currRing->options = si_opt_1 & TEST_RINGDEP_OPTS;
709  omFree((ADDRESS)n);
710  v=v->next;
711  } while (v!=NULL);
712 
713  // set global variable to show memory usage
714  extern int om_sing_opt_show_mem;
715  if (BVERBOSE(V_SHOW_MEM)) om_sing_opt_show_mem = 1;
716  else om_sing_opt_show_mem = 0;
717 
718  return FALSE;
719 }
720 
721 char * showOption()
722 {
723  int i;
724  BITSET tmp;
725 
726  StringSetS("//options:");
727  if ((si_opt_1!=0)||(si_opt_2!=0))
728  {
729  tmp=si_opt_1;
730  if(tmp)
731  {
732  for (i=0; optionStruct[i].setval!=0; i++)
733  {
734  if (optionStruct[i].setval & tmp)
735  {
736  StringAppend(" %s",optionStruct[i].name);
737  tmp &=optionStruct[i].resetval;
738  }
739  }
740  for (i=0; i<32; i++)
741  {
742  if (tmp & Sy_bit(i)) StringAppend(" %d",i);
743  }
744  }
745  tmp=si_opt_2;
746  if (tmp)
747  {
748  for (i=0; verboseStruct[i].setval!=0; i++)
749  {
750  if (verboseStruct[i].setval & tmp)
751  {
752  StringAppend(" %s",verboseStruct[i].name);
753  tmp &=verboseStruct[i].resetval;
754  }
755  }
756  for (i=1; i<32; i++)
757  {
758  if (tmp & Sy_bit(i)) StringAppend(" %d",i+32);
759  }
760  }
761  return StringEndS();
762  }
763  StringAppendS(" none");
764  return StringEndS();
765 }
766 
767 /* version strings */
768 #ifdef HAVE_FLINT
769 extern "C"
770 {
771 #ifndef __GMP_BITS_PER_MP_LIMB
772 #define __GMP_BITS_PER_MP_LIMB GMP_LIMB_BITS
773 #endif
774 #include <flint/flint.h>
775 }
776 #endif
777 
778 char * versionString(/*const bool bShowDetails = false*/ )
779 {
780  StringSetS("");
781  StringAppend("Singular for %s version %s (%d, %d bit) %s #%s",
782  S_UNAME, VERSION, // SINGULAR_VERSION,
783  SINGULAR_VERSION, SIZEOF_VOIDP*8, VERSION_DATE, GIT_VERSION);
784  StringAppendS("\nwith\n\t");
785 
786 #if defined(mpir_version)
787  StringAppend("MPIR(%s)~GMP(%s),", mpir_version, gmp_version);
788 #elif defined(gmp_version)
789  // #if defined (__GNU_MP_VERSION) && defined (__GNU_MP_VERSION_MINOR)
790  // StringAppend("GMP(%d.%d),",__GNU_MP_VERSION,__GNU_MP_VERSION_MINOR);
791  StringAppend("GMP(%s),", gmp_version);
792 #endif
793 #ifdef HAVE_NTL
794 #include <NTL/version.h>
795  StringAppend("NTL(%s),",NTL_VERSION);
796 #endif
797 
798 #ifdef HAVE_FLINT
799  StringAppend("FLINT(%s),",version);
800 #endif
801  StringAppend("factory(%s),\n\t", factoryVersion);
802 #if defined(HAVE_DYN_RL)
804  StringAppendS("no input,");
805  else if (fe_fgets_stdin==fe_fgets)
806  StringAppendS("fgets,");
808  StringAppendS("dynamic readline,");
809  #ifdef HAVE_FEREAD
811  StringAppendS("emulated readline,");
812  #endif
813  else
814  StringAppendS("unknown fgets method,");
815 #else
816  #if defined(HAVE_READLINE) && !defined(FEREAD)
817  StringAppendS("static readline,");
818  #else
819  #ifdef HAVE_FEREAD
820  StringAppendS("emulated readline,");
821  #else
822  StringAppendS("fgets,");
823  #endif
824  #endif
825 #endif
826 #ifdef HAVE_PLURAL
827  StringAppendS("Plural,");
828 #endif
829 #ifdef HAVE_DBM
830  StringAppendS("DBM,\n\t");
831 #else
832  StringAppendS("\n\t");
833 #endif
834 #ifdef HAVE_DYNAMIC_LOADING
835  StringAppendS("dynamic modules,");
836 #endif
837  if (p_procs_dynamic) StringAppendS("dynamic p_Procs,");
838 #if YYDEBUG
839  StringAppendS("YYDEBUG=1,");
840 #endif
841 #ifdef HAVE_ASSUME
842  StringAppendS("ASSUME,");
843 #endif
844 #ifdef MDEBUG
845  StringAppend("MDEBUG=%d,",MDEBUG);
846 #endif
847 #ifdef OM_CHECK
848  StringAppend("OM_CHECK=%d,",OM_CHECK);
849 #endif
850 #ifdef OM_TRACK
851  StringAppend("OM_TRACK=%d,",OM_TRACK);
852 #endif
853 #ifdef OM_NDEBUG
854  StringAppendS("OM_NDEBUG,");
855 #endif
856 #ifdef SING_NDEBUG
857  StringAppendS("SING_NDEBUG,");
858 #endif
859 #ifdef PDEBUG
860  StringAppendS("PDEBUG,");
861 #endif
862 #ifdef KDEBUG
863  StringAppendS("KDEBUG,");
864 #endif
865 #ifdef __OPTIMIZE__
866  StringAppendS("CC:OPTIMIZE,");
867 #endif
868 #ifdef __OPTIMIZE_SIZE__
869  StringAppendS("CC:OPTIMIZE_SIZE,");
870 #endif
871 #ifdef __NO_INLINE__
872  StringAppendS("CC:NO_INLINE,");
873 #endif
874 #ifdef HAVE_EIGENVAL
875  StringAppendS("eigenvalues,");
876 #endif
877 #ifdef HAVE_GMS
878  StringAppendS("Gauss-Manin system,");
879 #endif
880 #ifdef HAVE_RATGRING
881  StringAppendS("ratGB,");
882 #endif
883  StringAppend("random=%d\n",siRandomStart);
884 
885 #define SI_SHOW_BUILTIN_MODULE(name) StringAppend(" %s", #name);
886  StringAppendS("built-in modules: {");
888  StringAppendS("}\n");
889 #undef SI_SHOW_BUILTIN_MODULE
890 
891  StringAppend("AC_CONFIGURE_ARGS = %s,\n"
892  "CC = %s,FLAGS : %s,\n"
893  "CXX = %s,FLAGS : %s,\n"
894  "DEFS : %s,CPPFLAGS : %s,\n"
895  "LDFLAGS : %s,LIBS : %s "
896 #ifdef __GNUC__
897  "(ver: " __VERSION__ ")"
898 #endif
899  "\n",AC_CONFIGURE_ARGS, CC,CFLAGS, CXX,CXXFLAGS, DEFS,CPPFLAGS, LDFLAGS,LIBS);
902  StringAppendS("\n");
903  return StringEndS();
904 }
905 
906 #ifdef PDEBUG
907 #if (OM_TRACK > 2) && defined(OM_TRACK_CUSTOM)
908 void p_SetRingOfLeftv(leftv l, ring r)
909 {
910  switch(l->rtyp)
911  {
912  case INT_CMD:
913  case BIGINT_CMD:
914  case IDHDL:
915  case DEF_CMD:
916  break;
917  case POLY_CMD:
918  case VECTOR_CMD:
919  {
920  poly p=(poly)l->data;
921  while(p!=NULL) { p_SetRingOfLm(p,r); pIter(p); }
922  break;
923  }
924  case IDEAL_CMD:
925  case MODUL_CMD:
926  case MATRIX_CMD:
927  {
928  ideal I=(ideal)l->data;
929  int i;
930  for(i=IDELEMS(I)-1;i>=0;i--)
931  {
932  poly p=I->m[i];
933  while(p!=NULL) { p_SetRingOfLm(p,r); pIter(p); }
934  }
935  break;
936  }
937  case COMMAND:
938  {
939  command d=(command)l->data;
940  p_SetRingOfLeftv(&d->arg1, r);
941  if (d->argc>1) p_SetRingOfLeftv(&d->arg2, r);
942  if (d->argc>2) p_SetRingOfLeftv(&d->arg3, r);
943  break;
944  }
945  default:
946  printf("type %d not yet implementd in p_SetRingOfLeftv\n",l->rtyp);
947  break;
948  }
949 }
950 #endif
951 #endif
952 
953 #if 0 /* debug only */
954 void listall(int showproc)
955 {
956  idhdl hh=basePack->idroot;
957  PrintS("====== Top ==============\n");
958  while (hh!=NULL)
959  {
960  if (showproc || (IDTYP(hh)!=PROC_CMD))
961  {
962  if (IDDATA(hh)==(void *)currRing) PrintS("(R)");
963  else if (IDDATA(hh)==(void *)currPack) PrintS("(P)");
964  else PrintS(" ");
965  Print("::%s, typ %s level %d data %lx",
966  IDID(hh),Tok2Cmdname(IDTYP(hh)),IDLEV(hh),(long)IDDATA(hh));
967  if ((IDTYP(hh)==RING_CMD)
968  || (IDTYP(hh)==QRING_CMD))
969  Print(" ref: %d\n",IDRING(hh)->ref);
970  else
971  PrintLn();
972  }
973  hh=IDNEXT(hh);
974  }
975  hh=basePack->idroot;
976  while (hh!=NULL)
977  {
978  if (IDDATA(hh)==(void *)basePack)
979  Print("(T)::%s, typ %s level %d data %lx\n",
980  IDID(hh),Tok2Cmdname(IDTYP(hh)),IDLEV(hh),(long)IDDATA(hh));
981  else
982  if ((IDTYP(hh)==RING_CMD)
983  || (IDTYP(hh)==QRING_CMD)
984  || (IDTYP(hh)==PACKAGE_CMD))
985  {
986  Print("====== %s ==============\n",IDID(hh));
987  idhdl h2=IDRING(hh)->idroot;
988  while (h2!=NULL)
989  {
990  if (showproc || (IDTYP(h2)!=PROC_CMD))
991  {
992  if ((IDDATA(h2)==(void *)currRing)
993  && ((IDTYP(h2)==RING_CMD)||(IDTYP(h2)==QRING_CMD)))
994  PrintS("(R)");
995  else if (IDDATA(h2)==(void *)currPack) PrintS("(P)");
996  else PrintS(" ");
997  Print("%s::%s, typ %s level %d data %lx\n",
998  IDID(hh),IDID(h2),Tok2Cmdname(IDTYP(h2)),IDLEV(h2),(long)IDDATA(h2));
999  }
1000  h2=IDNEXT(h2);
1001  }
1002  }
1003  hh=IDNEXT(hh);
1004  }
1005  Print("currRing:%lx, currPack:%lx,basePack:%lx\n",(long)currRing,(long)currPack,(long)basePack);
1006  iiCheckPack(currPack);
1007 }
1008 #endif
1009 
1010 #ifndef SING_NDEBUG
1011 void checkall()
1012 {
1013  idhdl hh=basePack->idroot;
1014  while (hh!=NULL)
1015  {
1016  omCheckAddr(hh);
1017  omCheckAddr((ADDRESS)IDID(hh));
1018  if (RingDependend(IDTYP(hh)))
1019  {
1020  Print("%s typ %d in Top (should be in ring)\n",IDID(hh),IDTYP(hh));
1021  }
1022  hh=IDNEXT(hh);
1023  }
1024  hh=basePack->idroot;
1025  while (hh!=NULL)
1026  {
1027  if (IDTYP(hh)==PACKAGE_CMD)
1028  {
1029  idhdl h2=IDPACKAGE(hh)->idroot;
1030  if (IDPACKAGE(hh)!=basePack)
1031  {
1032  while (h2!=NULL)
1033  {
1034  omCheckAddr(h2);
1035  omCheckAddr((ADDRESS)IDID(h2));
1036  if (RingDependend(IDTYP(h2)))
1037  {
1038  Print("%s typ %d in %s (should be in ring)\n",IDID(h2),IDTYP(h2),IDID(hh));
1039  }
1040  h2=IDNEXT(h2);
1041  }
1042  }
1043  }
1044  hh=IDNEXT(hh);
1045  }
1046 }
1047 #endif
1048 
1049 #include <sys/types.h>
1050 #include <sys/stat.h>
1051 #include <unistd.h>
1052 
1053 extern "C"
1054 int singular_fstat(int fd, struct stat *buf)
1055 {
1056  return si_fstat(fd,buf);
1057 }
1058 
1059 /*2
1060 * the global exit routine of Singular
1061 */
1062 extern "C" {
1063 /* Note: We cannot use a mutex here because mutexes are not async-safe, but
1064  * m2_end is called by sig_term_hdl(). Anyway, the race condition in the first
1065  * few lines of m2_end() should not matter.
1066  */
1068 
1069 void m2_end(int i)
1070 {
1071  if (!m2_end_called)
1072  {
1073  extern FILE* File_Profiling;
1074  if (File_Profiling!=NULL) { fclose(File_Profiling); File_Profiling=NULL; }
1075  m2_end_called = TRUE;
1076 #ifdef HAVE_SIMPLEIPC
1077  for (int j = SIPC_MAX_SEMAPHORES-1; j >= 0; j--)
1078  {
1079  if (semaphore[j] != NULL)
1080  {
1081  while (sem_acquired[j] > 0)
1082  {
1083  sem_post(semaphore[j]);
1084  sem_acquired[j]--;
1085  }
1086  }
1087  }
1088 #endif // HAVE_SIMPLEIPC
1090  monitor(NULL,0);
1091 #ifdef PAGE_TEST
1092  mmEndStat();
1093 #endif
1096  {
1098  while(hh!=NULL)
1099  {
1100  //Print("close %s\n",hh->l->name);
1101  slPrepClose(hh->l);
1102  hh=(link_list)hh->next;
1103  }
1105 
1106  idhdl h = currPack->idroot;
1107  while(h != NULL)
1108  {
1109  if(IDTYP(h) == LINK_CMD)
1110  {
1111  idhdl hh=h->next;
1112  //Print("kill %s\n",IDID(h));
1113  killhdl(h, currPack);
1114  h = hh;
1115  }
1116  else
1117  {
1118  h = h->next;
1119  }
1120  }
1121  hh=ssiToBeClosed;
1122  while(hh!=NULL)
1123  {
1124  //Print("close %s\n",hh->l->name);
1125  slClose(hh->l);
1126  hh=ssiToBeClosed;
1127  }
1128  }
1129  if (!singular_in_batchmode)
1130  {
1131  if (i<=0)
1132  {
1133  if (TEST_V_QUIET)
1134  {
1135  if (i==0)
1136  printf("Auf Wiedersehen.\n");
1137  else
1138  printf("\n$Bye.\n");
1139  }
1140  //#ifdef sun
1141  // #ifndef __svr4__
1142  // _cleanup();
1143  // _exit(0);
1144  // #endif
1145  //#endif
1146  i=0;
1147  }
1148  else
1149  {
1150  printf("\nhalt %d\n",i);
1151  }
1152  }
1153  exit(i);
1154  }
1155 }
1156 }
1157 
1158 extern "C"
1159 {
1161  {
1162  fprintf(stderr, "\nSingular error: no more memory\n");
1163  omPrintStats(stderr);
1164  m2_end(14);
1165  /* should never get here */
1166  exit(1);
1167  }
1168 }
1169 
1170 #ifdef SINGULAR_4_1
1173 {
1174  if (a->Typ()!=INT_CMD)
1175  {
1176  WerrorS("`int` expected");
1177  return TRUE;
1178  }
1179  else
1180  {
1181  res->rtyp=CRING_CMD;
1182  res->data=(void*)nInitChar(n_pAE,(void*)a->Data());
1183  return FALSE;
1184  }
1185 }
1186 #ifdef HAVE_FLINT
1189 {
1190  if ((a->Typ()!=INT_CMD)
1191  ||(a->next==NULL)
1192  ||(a->next->Typ()!=STRING_CMD))
1193  {
1194  WerrorS("`int`i,`string` expected");
1195  return TRUE;
1196  }
1197  else
1198  {
1199  flintZn_struct p;
1200  p.ch=(int)(long)a->Data();
1201  p.name=(char*)a->next->Data();
1202  res->rtyp=CRING_CMD;
1203  res->data=(void*)nInitChar(n_FlintZn,(void*)&p);
1204  return FALSE;
1205  }
1206 }
1207 #endif
1208 #endif
1209 /*2
1210 * initialize components of Singular
1211 */
1212 void siInit(char *name)
1213 {
1214 // factory default settings: -----------------------------------------------
1215  On(SW_USE_EZGCD);
1217  //On(SW_USE_FF_MOD_GCD);
1218  On(SW_USE_EZGCD_P);
1219  On(SW_USE_QGCD);
1220  Off(SW_USE_NTL_SORT); // may be changed by an command line option
1222 
1223 // memory initialization: -----------------------------------------------
1224  om_Opts.OutOfMemoryFunc = omSingOutOfMemoryFunc;
1225 #ifndef OM_NDEBUG
1226 #ifndef __OPTIMIZE__
1227  om_Opts.ErrorHook = dErrorBreak;
1228 #else
1229  om_Opts.Keep = 0; /* !OM_NDEBUG, __OPTIMIZE__*/
1230 #endif
1231 #else
1232  om_Opts.Keep = 0; /* OM_NDEBUG */
1233 #endif
1234  omInitInfo();
1235 
1236 // options ---------------------------------------------------------------
1237  si_opt_1=0;
1238 // interpreter tables etc.: -----------------------------------------------
1239  memset(&sLastPrinted,0,sizeof(sleftv));
1241 
1242  extern int iiInitArithmetic(); iiInitArithmetic(); // iparith.cc
1243 
1244  basePack=(package)omAlloc0(sizeof(*basePack));
1246  idhdl h;
1247  h=enterid("Top", 0, PACKAGE_CMD, &IDROOT, TRUE);
1248  IDPACKAGE(h)->language = LANG_TOP;
1249  IDPACKAGE(h)=basePack;
1250  currPackHdl=h;
1251  basePackHdl=h;
1252 
1253  coeffs_BIGINT = nInitChar(n_Q,(void*)1);
1254 
1255 #if 1
1256  // def HAVE_POLYEXTENSIONS
1257  if(TRUE)
1258  {
1260  assume(type == n_algExt);
1261 
1262  type = nRegister(n_transExt, ntInitChar);
1263  assume(type == n_transExt);
1264 
1265  (void)type;
1266  }
1267 #endif
1268 
1269 // random generator: -----------------------------------------------
1270  int t=initTimer();
1271  if (t==0) t=1;
1272  initRTimer();
1273  siSeed=t;
1274  factoryseed(t);
1275  siRandomStart=t;
1276  feOptSpec[FE_OPT_RANDOM].value = (void*) ((long)siRandomStart);
1277 
1278 // ressource table: ----------------------------------------------------
1279  // Don't worry: ifdef OM_NDEBUG, then all these calls are undef'ed
1280  // hack such that all shared' libs in the bindir are loaded correctly
1281  feInitResources(name);
1282 
1283 // singular links: --------------------------------------------------
1284  slStandardInit();
1285  myynest=0;
1286 // semapohore 0 -----------------------------------------------------
1287  int cpus=2;
1288  int cpu_n;
1289  #ifdef _SC_NPROCESSORS_ONLN
1290  if ((cpu_n=sysconf(_SC_NPROCESSORS_ONLN))>cpus) cpus=cpu_n;
1291  #elif defined(_SC_NPROCESSORS_CONF)
1292  if ((cpu_n=sysconf(_SC_NPROCESSORS_CONF))>cpus) cpus=cpu_n;
1293  #endif
1294  feSetOptValue(FE_OPT_CPUS, cpus);
1295 
1296 #ifdef SINGULAR_4_1
1297 // default coeffs
1298  {
1299  idhdl h;
1300  h=enterid(omStrDup("QQ"),0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1301  IDDATA(h)=(char*)nInitChar(n_Q,NULL);
1302  h=enterid(omStrDup("ZZ"),0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1303  IDDATA(h)=(char*)nInitChar(n_Z,NULL);
1304  //h=enterid(omStrDup("RR"),0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1305  //IDDATA(h)=(char*)nInitChar(n_R,NULL);
1306  //h=enterid(omStrDup("CC"),0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1307  //IDDATA(h)=(char*)nInitChar(n_long_C,NULL);
1309  if (t!=n_unknown)
1310  {
1311  h=enterid(omStrDup("AE"),0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1312  IDDATA(h)=(char*)nInitChar(t,NULL);
1313  }
1315  if (t!=n_unknown)
1316  {
1317  h=enterid(omStrDup("QAE"),0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1318  IDDATA(h)=(char*)nInitChar(t,NULL);
1319  }
1321  if (n_pAE!=n_unknown)
1322  {
1323  iiAddCproc("kernel","pAE",FALSE,ii_pAE_init);
1324  }
1325  #ifdef HAVE_FLINT
1327  if (t!=n_unknown)
1328  {
1329  h=enterid(omStrDup("flint_poly_Q"),0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1330  IDDATA(h)=(char*)nInitChar(t,NULL);
1331  }
1333  if (n_FlintZn!=n_unknown)
1334  {
1335  iiAddCproc("kernel","flintZ",FALSE,ii_FlintZn_init);
1336  }
1337  #endif
1338  }
1339 #endif
1340 // setting routines for PLURAL QRINGS:
1341  nc_NF=k_NF;
1347 // loading standard.lib -----------------------------------------------
1348  if (! feOptValue(FE_OPT_NO_STDLIB))
1349  {
1350  BITSET save1,save2;
1351  SI_SAVE_OPT(save1,save2);
1352  si_opt_2 &= ~Sy_bit(V_LOAD_LIB);
1353  iiLibCmd(omStrDup("standard.lib"), TRUE,TRUE,TRUE);
1354  SI_RESTORE_OPT(save1,save2);
1355  }
1356  errorreported = 0;
1357 }
#define OPT_REDSB
Definition: options.h:71
BBA_Proc sca_mora
Definition: old.gring.cc:76
int iiInitArithmetic()
initialisation of arithmetic structured data
Definition: iparith.cc:9034
void m2_end(int i)
Definition: misc_ip.cc:1069
int status int fd
Definition: si_signals.h:59
BOOLEAN flintQ_InitChar(coeffs cf, void *infoStruct)
Definition: flintcf_Q.cc:564
#define TEST_V_QUIET
Definition: options.h:127
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
static void factor_gmp(mpz_t t, lists primes, int *multiplicities, int &index, unsigned long bound)
Definition: misc_ip.cc:303
poly k_NF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce, const ring _currRing)
NOTE: this is just a wrapper which sets currRing for the actual kNF call.
Definition: kstd1.cc:2919
ip_package * package
Definition: structs.h:46
void omSingOutOfMemoryFunc()
Definition: misc_ip.cc:1160
const CanonicalForm int s
Definition: facAbsFact.cc:55
unsigned si_opt_1
Definition: options.c:5
This file provides miscellaneous functionality.
sleftv * m
Definition: lists.h:45
#define OM_CHECK
Definition: omalloc_debug.c:15
char *(* fe_fgets_stdin)(const char *pr, char *s, int size)
Definition: feread.cc:33
const CanonicalForm int const CFList const Variable & y
Definition: facAbsFact.cc:57
#define OPT_PROT
Definition: options.h:70
BOOLEAN n_AEInitChar(coeffs r, void *)
Definition: OPAE.cc:344
void factoryseed(int s)
random seed initializer
Definition: cf_random.cc:176
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
ideal k_gnc_gr_bba(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat, const ring _currRing)
Definition: gr_kstd2.cc:1055
void singular_example(char *str)
Definition: misc_ip.cc:439
#define MAXPATHLEN
Definition: omRet2Info.c:22
ip_command * command
Definition: ipid.h:24
#define V_COEFSTRAT
Definition: options.h:59
static FORCE_INLINE void number2mpz(number n, mpz_t m)
Definition: misc_ip.cc:46
const poly a
Definition: syzextra.cc:212
void PrintLn()
Definition: reporter.cc:327
static CanonicalForm bound(const CFMatrix &M)
Definition: cf_linsys.cc:460
#define Print
Definition: emacs.cc:83
void feStringAppendResources(int warn)
Definition: reporter.cc:415
Definition: tok.h:98
const BOOLEAN p_procs_dynamic
ideal k_sca_bba(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat, const ring _currRing)
Modified modern Sinuglar Buchberger&#39;s algorithm.
Definition: sca.cc:375
ideal k_sca_gr_bba(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat, const ring _currRing)
Modified Plural&#39;s Buchberger&#39;s algorithmus.
Definition: sca.cc:101
#define OPT_INFREDTAIL
Definition: options.h:89
static void * feOptValue(feOptIndex opt)
Definition: feOpt.h:40
void Off(int sw)
switches
idhdl currPackHdl
Definition: ipid.cc:61
#define V_LENGTH
Definition: options.h:61
Definition: lists.h:22
BOOLEAN naInitChar(coeffs cf, void *infoStruct)
Initialize the coeffs object.
Definition: algext.cc:1389
ideal k_sca_mora(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat, const ring _currRing)
Modified modern Sinuglar Mora&#39;s algorithm.
Definition: sca.cc:897
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:38
loop
Definition: myNF.cc:98
#define IDID(a)
Definition: ipid.h:121
volatile BOOLEAN m2_end_called
Definition: misc_ip.cc:1067
#define FALSE
Definition: auxiliary.h:140
Definition: tok.h:42
return P p
Definition: myNF.cc:203
static n_coeffType n_FlintZn
Definition: misc_ip.cc:1187
static void factor_using_pollard_rho(mpz_t n, unsigned long a, lists primes, int *multiplicities, int &index)
Definition: misc_ip.cc:180
void siInit(char *name)
Definition: misc_ip.cc:1212
void setListEntry(lists L, int index, mpz_t n)
Definition: misc_ip.cc:50
#define V_LOAD_LIB
Definition: options.h:45
#define SINGULAR_VERSION
Definition: mod2.h:94
static unsigned add[]
Definition: misc_ip.cc:83
static char * feResource(feResourceConfig config, int warn)
Definition: feResource.cc:258
#define OPT_MULTBOUND
Definition: options.h:84
const struct soptionStruct optionStruct[]
Definition: misc_ip.cc:516
char * fe_fgets(const char *pr, char *s, int size)
Definition: feread.cc:310
static const int SW_USE_EZGCD_P
set to 1 to use EZGCD over F_q
Definition: cf_defs.h:34
rational (GMP) numbers
Definition: coeffs.h:31
#define V_DEF_RES
Definition: options.h:48
#define OPT_NO_SYZ_MINIM
Definition: options.h:78
char * showOption()
Definition: misc_ip.cc:721
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:539
int singular_fstat(int fd, struct stat *buf)
Definition: misc_ip.cc:1054
#define IDNEXT(a)
Definition: ipid.h:117
#define V_FINDMONOM
Definition: options.h:58
BOOLEAN n_QAEInitChar(coeffs r, void *)
Definition: OPAEQ.cc:336
#define IDROOT
Definition: ipid.h:20
char * fe_fgets_dummy(const char *, char *, int)
Definition: feread.cc:418
#define OPT_OLDSTD
Definition: options.h:81
int siRandomStart
Definition: cntrlc.cc:103
static const int SW_USE_NTL_SORT
set to 1 to sort factors in a factorization
Definition: cf_defs.h:36
#define TRUE
Definition: auxiliary.h:144
#define FORCE_INLINE
Definition: auxiliary.h:386
static unsigned short primes[]
primes, primes_len: used to step through possible extensions
void * ADDRESS
Definition: auxiliary.h:161
FILE * File_Profiling
Definition: fevoices.cc:38
unsigned setval
Definition: ipid.h:154
unsigned resetval
Definition: ipid.h:155
void * value
Definition: fegetopt.h:93
SI_FOREACH_BUILTIN(SI_GET_BUILTIN_MOD_INIT0)}
const char * feSetOptValue(feOptIndex opt, char *optarg)
Definition: feOpt.cc:153
void feInitResources(const char *argv0)
Definition: feResource.cc:170
void WerrorS(const char *s)
Definition: feFopen.cc:24
void initRTimer()
Definition: timer.cc:158
void omPrintStats(FILE *fd)
Definition: omStats.c:114
int k
Definition: cfEzgcd.cc:93
char * StringEndS()
Definition: reporter.cc:151
static n_coeffType n_pAE
Definition: misc_ip.cc:1171
idhdl basePackHdl
Definition: ipid.cc:62
#define V_DEBUG_LIB
Definition: options.h:46
#define V_INTERSECT_ELIM
Definition: options.h:64
#define BITSET
Definition: structs.h:17
coeffs coeffs_BIGINT
Definition: ipid.cc:54
int Typ()
Definition: subexpr.cc:976
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define Sy_bit(x)
Definition: options.h:30
static FORCE_INLINE number mpz2number(mpz_t m)
Definition: misc_ip.cc:47
BOOLEAN iiLibCmd(char *newlib, BOOLEAN autoexport, BOOLEAN tellerror, BOOLEAN force)
Definition: iplib.cc:803
Definition: idrec.h:34
#define IDHDL
Definition: tok.h:35
char * versionString()
Definition: misc_ip.cc:778
void checkall()
Definition: misc_ip.cc:1011
void monitor(void *F, int mode)
Definition: febase.cc:72
BITSET validOpts
Definition: kstd1.cc:70
omOpts_t om_Opts
Definition: omOpts.c:11
BBA_Proc gnc_gr_bba
Definition: old.gring.cc:73
static BOOLEAN rField_has_simple_inverse(const ring r)
Definition: ring.h:494
void * data
Definition: subexpr.h:89
void feStringAppendBrowsers(int warn)
Definition: fehelp.cc:352
void setListEntry_ui(lists L, int index, unsigned long ui)
Definition: misc_ip.cc:67
#define pIter(p)
Definition: monomials.h:44
#define V_QRING
Definition: options.h:40
poly res
Definition: myNF.cc:322
#define IDPACKAGE(a)
Definition: ipid.h:138
int myynest
Definition: febase.cc:46
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
#define V_SHOW_USE
Definition: options.h:50
#define IDTYP(a)
Definition: ipid.h:118
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:259
#define V_SHOW_MEM
Definition: options.h:41
Definition: tok.h:59
int RingDependend(int t)
Definition: gentable.cc:23
sem_t * semaphore[SIPC_MAX_SEMAPHORES]
Definition: semaphore.c:29
const ring r
Definition: syzextra.cc:208
#define SI_RESTORE_OPT(A, B)
Definition: options.h:22
BOOLEAN singular_in_batchmode
Definition: cntrlc.cc:72
#define MDEBUG
Definition: mod2.h:196
Coefficient rings, fields and other domains suitable for Singular polynomials.
void omInitInfo()
Definition: omStats.c:17
#define TEST_OPT_INTSTRATEGY
Definition: options.h:105
Definition: intvec.h:14
n_coeffType nRegister(n_coeffType n, cfInitCharProc p)
Definition: numbers.cc:518
#define OPT_REDTAIL
Definition: options.h:86
#define OPT_NOT_BUCKETS
Definition: options.h:72
int j
Definition: myNF.cc:70
Definition: tok.h:61
const char * name
Definition: subexpr.h:88
BBA_Proc sca_bba
Definition: old.gring.cc:75
#define omFree(addr)
Definition: omAllocDecl.h:261
#define p_SetRingOfLm(p, r)
Definition: monomials.h:152
BBA_Proc gnc_gr_mora
Definition: old.gring.cc:74
#define assume(x)
Definition: mod2.h:405
char * fe_fgets_stdin_emu(const char *pr, char *s, int size)
Definition: feread.cc:254
void StringSetS(const char *st)
Definition: reporter.cc:128
int status int void * buf
Definition: si_signals.h:59
void StringAppendS(const char *st)
Definition: reporter.cc:107
static BOOLEAN ii_FlintZn_init(leftv res, leftv a)
Definition: misc_ip.cc:1188
struct fe_option feOptSpec[]
#define OPT_NOT_SUGAR
Definition: options.h:73
void fe_reset_input_mode()
Definition: fereadl.c:826
All the auxiliary stuff.
#define V_CONTENTSB
Definition: options.h:54
#define V_UPTORADICAL
Definition: options.h:57
int m
Definition: cfEzgcd.cc:119
#define OPT_STAIRCASEBOUND
Definition: options.h:83
only used if HAVE_RINGS is defined: ?
Definition: coeffs.h:42
void On(int sw)
switches
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
Definition: feFopen.cc:47
#define StringAppend
Definition: emacs.cc:82
FILE * f
Definition: checklibs.c:7
int i
Definition: cfEzgcd.cc:123
void PrintS(const char *s)
Definition: reporter.cc:294
ideal k_gnc_gr_mora(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat, const ring _currRing)
Definition: gr_kstd2.cc:1317
const struct soptionStruct verboseStruct[]
Definition: misc_ip.cc:546
idhdl next
Definition: idrec.h:38
#define version
Definition: libparse.cc:1260
static const int SW_USE_CHINREM_GCD
set to 1 to use modular gcd over Z
Definition: cf_defs.h:38
#define IDELEMS(i)
Definition: simpleideals.h:24
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:465
BOOLEAN iiEStart(char *example, procinfo *pi)
Definition: iplib.cc:655
#define IDLEV(a)
Definition: ipid.h:120
#define V_READING
Definition: options.h:44
short errorreported
Definition: feFopen.cc:23
leftv next
Definition: subexpr.h:87
static int index(p_Length length, p_Ord ord)
Definition: p_Procs_Impl.h:592
#define OPT_SUGARCRIT
Definition: options.h:75
#define OPT_INTSTRATEGY
Definition: options.h:87
#define BVERBOSE(a)
Definition: options.h:33
INLINE_THIS void Init(int l=0)
Definition: lists.h:66
CanonicalForm test
Definition: cfModGcd.cc:4037
#define V_LOAD_PROC
Definition: options.h:47
#define IDPROC(a)
Definition: ipid.h:139
#define V_ALLWARN
Definition: options.h:63
#define OPT_DEBUG
Definition: options.h:76
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
BOOLEAN flintZn_InitChar(coeffs cf, void *infoStruct)
Definition: flintcf_Zn.cc:470
BOOLEAN n_pAEInitChar(coeffs r, void *p)
Definition: OPAEp.cc:351
#define mpz_size1(A)
Definition: si_gmp.h:12
n_coeffType
Definition: coeffs.h:27
char name(const Variable &v)
Definition: variable.h:95
#define V_YACC
Definition: options.h:42
#define SEEK_END
Definition: mod2.h:121
Definition: tok.h:119
#define OM_TRACK
Definition: omalloc_debug.c:10
#define V_PROMPT
Definition: options.h:52
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:434
#define NULL
Definition: omList.c:10
#define VERSION
Definition: mod2.h:21
slists * lists
Definition: mpr_numeric.h:146
#define OPT_WEIGHTM
Definition: options.h:92
int yydebug
Definition: grammar.cc:1791
lists primeFactorisation(const number n, const int pBound)
Factorises a given bigint number n into its prime factors less than or equal to a given bound...
Definition: misc_ip.cc:333
int siSeed
Definition: sirandom.c:29
const char * Tok2Cmdname(int tok)
Definition: gentable.cc:128
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic ...
Definition: coeffs.h:35
#define V_NSB
Definition: options.h:53
#define V_CANCELUNIT
Definition: options.h:55
void killhdl(idhdl h, package proot)
Definition: ipid.cc:372
package basePack
Definition: ipid.cc:64
static const int SW_USE_QGCD
set to 1 to use Encarnacion GCD over Q(a)
Definition: cf_defs.h:40
static const int SW_USE_EZGCD
set to 1 to use EZGCD over Z
Definition: cf_defs.h:32
#define IDRING(a)
Definition: ipid.h:126
const CanonicalForm & w
Definition: facAbsFact.cc:55
package currPack
Definition: ipid.cc:63
Variable x
Definition: cfModGcd.cc:4023
int rtyp
Definition: subexpr.h:92
#define SI_SAVE_OPT(A, B)
Definition: options.h:19
sleftv sLastPrinted
Definition: subexpr.cc:55
#define SIPC_MAX_SEMAPHORES
Definition: simpleipc.h:10
void Clean(ring r=currRing)
Definition: lists.h:25
void * Data()
Definition: subexpr.cc:1118
#define OPT_REDTHROUGH
Definition: options.h:77
int initTimer()
Definition: timer.cc:69
#define V_INTERSECT_SYZ
Definition: options.h:65
Definition: tok.h:120
char * iiGetLibName(procinfov pi)
Definition: iplib.cc:102
#define SI_SHOW_BUILTIN_MODULE(name)
omBin slists_bin
Definition: lists.cc:23
const char factoryVersion[]
extern const char factoryVersion[];
Definition: tok.h:159
NF_Proc nc_NF
Definition: old.gring.cc:72
#define TEST_RINGDEP_OPTS
Definition: options.h:95
#define omCheckAddr(addr)
Definition: omAllocDecl.h:328
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff &#39;n&#39; is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long representing n in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or (Im(n) == 0 and Re(n) >= 0) in K(a)/<p(a)>: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0)) in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0) or (LC(numerator(n) is not a constant) in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1) in Z/mZ: TRUE iff the internal mpz is greater than zero in Z: TRUE iff n > 0
Definition: coeffs.h:495
void iiCheckPack(package &p)
Definition: ipshell.cc:1516
#define SEEK_SET
Definition: mod2.h:125
#define OPT_DEGBOUND
Definition: options.h:85
int iiAddCproc(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
Definition: iplib.cc:993
kBucketDestroy & P
Definition: myNF.cc:191
polyrec * poly
Definition: hilb.h:10
#define IDDATA(a)
Definition: ipid.h:125
#define OPT_NOTREGULARITY
Definition: options.h:91
char * fe_fgets_stdin_drl(const char *pr, char *s, int size)
Definition: feread.cc:270
int sem_acquired[SIPC_MAX_SEMAPHORES]
Definition: semaphore.c:30
static int factor_using_division(mpz_t t, unsigned int limit, lists primes, int *multiplicities, int &index, unsigned long bound)
Definition: misc_ip.cc:85
#define OPT_INTERRUPT
Definition: options.h:74
BBA_Proc sca_gr_bba
Definition: old.gring.cc:77
unsigned si_opt_2
Definition: options.c:6
char * iiGetLibProcBuffer(procinfo *pi, int part)
Definition: iplib.cc:211
static Poly * h
Definition: janet.cc:978
int BOOLEAN
Definition: auxiliary.h:131
static BOOLEAN ii_pAE_init(leftv res, leftv a)
Definition: misc_ip.cc:1172
#define NONE
Definition: tok.h:220
#define V_REDEFINE
Definition: options.h:43
void dErrorBreak()
Definition: dError.cc:141
void Werror(const char *fmt,...)
Definition: reporter.cc:199
#define OPT_FASTHC
Definition: options.h:80
void * CopyD(int t)
Definition: subexpr.cc:676
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int l
Definition: cfEzgcd.cc:94
#define V_MODPSOLVSB
Definition: options.h:56
int si_echo
Definition: febase.cc:41
void(* factoryError)(const char *s)
Definition: cf_util.cc:75
BOOLEAN setOption(leftv res, leftv v)
Definition: misc_ip.cc:575
#define COMMAND
Definition: tok.h:33
#define OPT_RETURN_SB
Definition: options.h:79
#define V_IMAP
Definition: options.h:51
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:327
BOOLEAN ntInitChar(coeffs cf, void *infoStruct)
Initialize the coeffs object.
Definition: transext.cc:2539
#define Warn
Definition: emacs.cc:80
#define omStrDup(s)
Definition: omAllocDecl.h:263