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