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