Macros | Functions | Variables
misc_ip.cc File Reference

This file provides miscellaneous functionality. More...

#include <kernel/mod2.h>
#include <misc/auxiliary.h>
#include <misc/sirandom.h>
#include <reporter/si_signals.h>
#include <factory/factory.h>
#include <coeffs/si_gmp.h>
#include <coeffs/coeffs.h>
#include <coeffs/OPAE.h>
#include <coeffs/OPAEQ.h>
#include <coeffs/OPAEp.h>
#include <coeffs/flintcf_Q.h>
#include <coeffs/flintcf_Zn.h>
#include <polys/ext_fields/algext.h>
#include <polys/ext_fields/transext.h>
#include <polys/nc/gb_hack.h>
#include <Singular/links/simpleipc.h>
#include "misc_ip.h"
#include "ipid.h"
#include "feOpt.h"
#include "links/silink.h"
#include "mod_lib.h"
#include <omalloc/omalloc.h>
#include <misc/mylimits.h>
#include <misc/options.h>
#include <misc/intvec.h>
#include <polys/monomials/ring.h>
#include <polys/templates/p_Procs.h>
#include <kernel/GBEngine/kstd1.h>
#include <kernel/oswrapper/timer.h>
#include <resources/feResource.h>
#include <kernel/oswrapper/feread.h>
#include "subexpr.h"
#include "cntrlc.h"
#include "ipshell.h"
#include "fehelp.h"
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <time.h>
#include <flint/flint.h>
#include <NTL/version.h>
#include <sys/types.h>
#include <sys/stat.h>

Go to the source code of this file.

Macros

#define PLURAL_INTERNAL_DECLARATIONS   1
 
#define SI_SHOW_BUILTIN_MODULE(name)   StringAppend(" %s", #name);
 

Functions

static FORCE_INLINE void number2mpz (number n, mpz_t m)
 
static FORCE_INLINE number mpz2number (mpz_t m)
 
void setListEntry (lists L, int index, mpz_t n)
 
void setListEntry_ui (lists L, int index, unsigned long ui)
 
static int factor_using_division (mpz_t t, unsigned int limit, lists primes, int *multiplicities, int &index, unsigned long bound)
 
static void factor_using_pollard_rho (mpz_t n, unsigned long a, lists primes, int *multiplicities, int &index)
 
static void factor_gmp (mpz_t t, lists primes, int *multiplicities, int &index, unsigned long bound)
 
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, with corresponding multiplicities. More...
 
void singular_example (char *str)
 
BOOLEAN setOption (leftv res, leftv v)
 
char * showOption ()
 
char * versionString ()
 
void checkall ()
 
int singular_fstat (int fd, struct stat *buf)
 
void m2_end (int i)
 
void omSingOutOfMemoryFunc ()
 
static BOOLEAN ii_pAE_init (leftv res, leftv a)
 
static BOOLEAN ii_FlintZn_init (leftv res, leftv a)
 
void siInit (char *name)
 

Variables

static unsigned add [] = {4, 2, 4, 2, 4, 6, 2, 6}
 
const struct soptionStruct optionStruct []
 
const struct soptionStruct verboseStruct []
 
volatile BOOLEAN m2_end_called = FALSE
 
static n_coeffType n_pAE =n_unknown
 
static n_coeffType n_FlintZn =n_unknown
 

Detailed Description

This file provides miscellaneous functionality.

For more general information, see the documentation in misc_ip.h.

Definition in file misc_ip.cc.

Macro Definition Documentation

#define PLURAL_INTERNAL_DECLARATIONS   1

Definition at line 14 of file misc_ip.cc.

#define SI_SHOW_BUILTIN_MODULE (   name)    StringAppend(" %s", #name);

Function Documentation

void checkall ( )

Definition at line 1011 of file misc_ip.cc.

1012 {
1013  idhdl hh=basePack->idroot;
1014  while (hh!=NULL)
1015  {
1016  omCheckAddr(hh);
1017  omCheckAddr((ADDRESS)IDID(hh));
1018  if (RingDependend(IDTYP(hh)))
1019  {
1020  Print("%s typ %d in Top (should be in ring)\n",IDID(hh),IDTYP(hh));
1021  }
1022  hh=IDNEXT(hh);
1023  }
1024  hh=basePack->idroot;
1025  while (hh!=NULL)
1026  {
1027  if (IDTYP(hh)==PACKAGE_CMD)
1028  {
1029  idhdl h2=IDPACKAGE(hh)->idroot;
1030  if (IDPACKAGE(hh)!=basePack)
1031  {
1032  while (h2!=NULL)
1033  {
1034  omCheckAddr(h2);
1035  omCheckAddr((ADDRESS)IDID(h2));
1036  if (RingDependend(IDTYP(h2)))
1037  {
1038  Print("%s typ %d in %s (should be in ring)\n",IDID(h2),IDTYP(h2),IDID(hh));
1039  }
1040  h2=IDNEXT(h2);
1041  }
1042  }
1043  }
1044  hh=IDNEXT(hh);
1045  }
1046 }
#define Print
Definition: emacs.cc:83
#define IDID(a)
Definition: ipid.h:121
#define IDNEXT(a)
Definition: ipid.h:117
void * ADDRESS
Definition: auxiliary.h:161
Definition: idrec.h:34
#define IDPACKAGE(a)
Definition: ipid.h:138
#define IDTYP(a)
Definition: ipid.h:118
int RingDependend(int t)
Definition: gentable.cc:23
#define NULL
Definition: omList.c:10
package basePack
Definition: ipid.cc:64
#define omCheckAddr(addr)
Definition: omAllocDecl.h:328
static void factor_gmp ( mpz_t  t,
lists  primes,
int *  multiplicities,
int &  index,
unsigned long  bound 
)
static

Definition at line 303 of file misc_ip.cc.

304 {
305  unsigned int division_limit;
306 
307  if (mpz_sgn (t) == 0)
308  return;
309 
310  /* Set the trial division limit according the size of t. */
311  division_limit = mpz_sizeinbase (t, 2);
312  if (division_limit > 1000)
313  division_limit = 1000 * 1000;
314  else
315  division_limit = division_limit * division_limit;
316 
317  if (factor_using_division (t, division_limit,primes,multiplicities,index,bound))
318  {
319  if (mpz_cmp_ui (t, 1) != 0)
320  {
321  if (mpz_probab_prime_p (t, 10))
322  {
323  setListEntry(primes, index, t);
324  multiplicities[index++] = 1;
325  mpz_set_ui(t,1);
326  }
327  else
328  factor_using_pollard_rho (t, 1L, primes,multiplicities,index);
329  }
330  }
331 }
static CanonicalForm bound(const CFMatrix &M)
Definition: cf_linsys.cc:460
static void factor_using_pollard_rho(mpz_t n, unsigned long a, lists primes, int *multiplicities, int &index)
Definition: misc_ip.cc:180
void setListEntry(lists L, int index, mpz_t n)
Definition: misc_ip.cc:50
static int index(p_Length length, p_Ord ord)
Definition: p_Procs_Impl.h:592
static int factor_using_division(mpz_t t, unsigned int limit, lists primes, int *multiplicities, int &index, unsigned long bound)
Definition: misc_ip.cc:85
static int factor_using_division ( mpz_t  t,
unsigned int  limit,
lists  primes,
int *  multiplicities,
int &  index,
unsigned long  bound 
)
static

Definition at line 85 of file misc_ip.cc.

86 {
87  mpz_t q, r;
88  unsigned long int f;
89  int ai;
90  unsigned *addv = add;
91  unsigned int failures;
92  int bound_not_reached=1;
93 
94  mpz_init (q);
95  mpz_init (r);
96 
97  f = mpz_scan1 (t, 0);
98  mpz_div_2exp (t, t, f);
99  if (f>0)
100  {
101  setListEntry_ui(primes, index, 2);
102  multiplicities[index++] = f;
103  }
104 
105  f=0;
106  loop
107  {
108  mpz_tdiv_qr_ui (q, r, t, 3);
109  if (mpz_cmp_ui (r, 0) != 0)
110  break;
111  mpz_set (t, q);
112  f++;
113  }
114  if (f>0)
115  {
116  setListEntry_ui(primes, index, 3);
117  multiplicities[index++] = f;
118  }
119  f=0;
120  loop
121  {
122  mpz_tdiv_qr_ui (q, r, t, 5);
123  if (mpz_cmp_ui (r, 0) != 0)
124  break;
125  mpz_set (t, q);
126  f++;
127  }
128  if (f>0)
129  {
130  setListEntry_ui(primes, index, 5);
131  multiplicities[index++] = f;
132  }
133 
134  failures = 0;
135  f = 7;
136  ai = 0;
137  unsigned long last_f=0;
138  while (mpz_cmp_ui (t, 1) != 0)
139  {
140  mpz_tdiv_qr_ui (q, r, t, f);
141  if (mpz_cmp_ui (r, 0) != 0)
142  {
143  f += addv[ai];
144  if (mpz_cmp_ui (t, f) < 0)
145  break;
146  ai = (ai + 1) & 7;
147  failures++;
148  if (failures > limit)
149  break;
150  if ((bound!=0) && (f>bound))
151  {
152  bound_not_reached=0;
153  break;
154  }
155  }
156  else
157  {
158  mpz_swap (t, q);
159  if (f!=last_f)
160  {
161  setListEntry_ui(primes, index, f);
162  multiplicities[index]++;
163  index++;
164  }
165  else
166  {
167  multiplicities[index-1]++;
168  }
169  last_f=f;
170  failures = 0;
171  }
172  }
173 
174  mpz_clear (q);
175  mpz_clear (r);
176  //printf("bound=%d,f=%d,failures=%d, reached=%d\n",bound,f,failures,bound_not_reached);
177  return bound_not_reached;
178 }
static CanonicalForm bound(const CFMatrix &M)
Definition: cf_linsys.cc:460
loop
Definition: myNF.cc:98
static unsigned add[]
Definition: misc_ip.cc:83
void setListEntry_ui(lists L, int index, unsigned long ui)
Definition: misc_ip.cc:67
const ring r
Definition: syzextra.cc:208
FILE * f
Definition: checklibs.c:7
static int index(p_Length length, p_Ord ord)
Definition: p_Procs_Impl.h:592
static void factor_using_pollard_rho ( mpz_t  n,
unsigned long  a,
lists  primes,
int *  multiplicities,
int &  index 
)
static

Definition at line 180 of file misc_ip.cc.

181 {
182  mpz_t x, x1, y, P;
183  mpz_t t1, t2;
184  mpz_t last_f;
185  unsigned long long k, l, i;
186 
187  mpz_init (t1);
188  mpz_init (t2);
189  mpz_init_set_si (last_f, 0);
190  mpz_init_set_si (y, 2);
191  mpz_init_set_si (x, 2);
192  mpz_init_set_si (x1, 2);
193  mpz_init_set_ui (P, 1);
194  k = 1;
195  l = 1;
196 
197  while (mpz_cmp_ui (n, 1) != 0)
198  {
199  loop
200  {
201  do
202  {
203  mpz_mul (t1, x, x);
204  mpz_mod (x, t1, n);
205  mpz_add_ui (x, x, a);
206  mpz_sub (t1, x1, x);
207  mpz_mul (t2, P, t1);
208  mpz_mod (P, t2, n);
209 
210  if (k % 32 == 1)
211  {
212  mpz_gcd (t1, P, n);
213  if (mpz_cmp_ui (t1, 1) != 0)
214  goto factor_found;
215  mpz_set (y, x);
216  }
217  }
218  while (--k != 0);
219 
220  mpz_gcd (t1, P, n);
221  if (mpz_cmp_ui (t1, 1) != 0)
222  goto factor_found;
223 
224  mpz_set (x1, x);
225  k = l;
226  l = 2 * l;
227  for (i = 0; i < k; i++)
228  {
229  mpz_mul (t1, x, x);
230  mpz_mod (x, t1, n);
231  mpz_add_ui (x, x, a);
232  }
233  mpz_set (y, x);
234  }
235 
236  factor_found:
237  do
238  {
239  mpz_mul (t1, y, y);
240  mpz_mod (y, t1, n);
241  mpz_add_ui (y, y, a);
242  mpz_sub (t1, x1, y);
243  mpz_gcd (t1, t1, n);
244  }
245  while (mpz_cmp_ui (t1, 1) == 0);
246 
247  mpz_divexact (n, n, t1); /* divide by t1, before t1 is overwritten */
248 
249  if (!mpz_probab_prime_p (t1, 10))
250  {
251  do
252  {
253  mp_limb_t a_limb;
254  mpn_random (&a_limb, (mp_size_t) 1);
255  a = a_limb;
256  }
257  while (a == 0);
258 
259  factor_using_pollard_rho (t1, a, primes,multiplicities,index);
260  }
261  else
262  {
263  if (mpz_cmp(t1,last_f)==0)
264  {
265  multiplicities[index-1]++;
266  }
267  else
268  {
269  mpz_set(last_f,t1);
270  setListEntry(primes, index, t1);
271  multiplicities[index++] = 1;
272  }
273  }
274  mpz_mod (x, x, n);
275  mpz_mod (x1, x1, n);
276  mpz_mod (y, y, n);
277  if (mpz_probab_prime_p (n, 10))
278  {
279  if (mpz_cmp(n,last_f)==0)
280  {
281  multiplicities[index-1]++;
282  }
283  else
284  {
285  mpz_set(last_f,n);
286  setListEntry(primes, index, n);
287  multiplicities[index++] = 1;
288  }
289  mpz_set_ui(n,1);
290  break;
291  }
292  }
293 
294  mpz_clear (P);
295  mpz_clear (t2);
296  mpz_clear (t1);
297  mpz_clear (x1);
298  mpz_clear (x);
299  mpz_clear (y);
300  mpz_clear (last_f);
301 }
const CanonicalForm int const CFList const Variable & y
Definition: facAbsFact.cc:57
const poly a
Definition: syzextra.cc:212
loop
Definition: myNF.cc:98
static void factor_using_pollard_rho(mpz_t n, unsigned long a, lists primes, int *multiplicities, int &index)
Definition: misc_ip.cc:180
void setListEntry(lists L, int index, mpz_t n)
Definition: misc_ip.cc:50
int k
Definition: cfEzgcd.cc:93
int i
Definition: cfEzgcd.cc:123
static int index(p_Length length, p_Ord ord)
Definition: p_Procs_Impl.h:592
Variable x
Definition: cfModGcd.cc:4023
kBucketDestroy & P
Definition: myNF.cc:191
int l
Definition: cfEzgcd.cc:94
static BOOLEAN ii_FlintZn_init ( leftv  res,
leftv  a 
)
static

Definition at line 1188 of file misc_ip.cc.

1189 {
1190  if ((a->Typ()!=INT_CMD)
1191  ||(a->next==NULL)
1192  ||(a->next->Typ()!=STRING_CMD))
1193  {
1194  WerrorS("`int`i,`string` expected");
1195  return TRUE;
1196  }
1197  else
1198  {
1199  flintZn_struct p;
1200  p.ch=(int)(long)a->Data();
1201  p.name=(char*)a->next->Data();
1202  res->rtyp=CRING_CMD;
1203  res->data=(void*)nInitChar(n_FlintZn,(void*)&p);
1204  return FALSE;
1205  }
1206 }
Definition: tok.h:98
#define FALSE
Definition: auxiliary.h:140
return P p
Definition: myNF.cc:203
static n_coeffType n_FlintZn
Definition: misc_ip.cc:1187
#define TRUE
Definition: auxiliary.h:144
void WerrorS(const char *s)
Definition: feFopen.cc:24
int Typ()
Definition: subexpr.cc:976
void * data
Definition: subexpr.h:89
Definition: tok.h:59
leftv next
Definition: subexpr.h:87
#define NULL
Definition: omList.c:10
int rtyp
Definition: subexpr.h:92
void * Data()
Definition: subexpr.cc:1118
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:327
static BOOLEAN ii_pAE_init ( leftv  res,
leftv  a 
)
static

Definition at line 1172 of file misc_ip.cc.

1173 {
1174  if (a->Typ()!=INT_CMD)
1175  {
1176  WerrorS("`int` expected");
1177  return TRUE;
1178  }
1179  else
1180  {
1181  res->rtyp=CRING_CMD;
1182  res->data=(void*)nInitChar(n_pAE,(void*)a->Data());
1183  return FALSE;
1184  }
1185 }
Definition: tok.h:98
#define FALSE
Definition: auxiliary.h:140
#define TRUE
Definition: auxiliary.h:144
void WerrorS(const char *s)
Definition: feFopen.cc:24
static n_coeffType n_pAE
Definition: misc_ip.cc:1171
int Typ()
Definition: subexpr.cc:976
void * data
Definition: subexpr.h:89
Definition: tok.h:59
int rtyp
Definition: subexpr.h:92
void * Data()
Definition: subexpr.cc:1118
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:327
void m2_end ( int  i)

Definition at line 1069 of file misc_ip.cc.

1070 {
1071  if (!m2_end_called)
1072  {
1073  extern FILE* File_Profiling;
1074  if (File_Profiling!=NULL) { fclose(File_Profiling); File_Profiling=NULL; }
1075  m2_end_called = TRUE;
1076 #ifdef HAVE_SIMPLEIPC
1077  for (int j = SIPC_MAX_SEMAPHORES-1; j >= 0; j--)
1078  {
1079  if (semaphore[j] != NULL)
1080  {
1081  while (sem_acquired[j] > 0)
1082  {
1083  sem_post(semaphore[j]);
1084  sem_acquired[j]--;
1085  }
1086  }
1087  }
1088 #endif // HAVE_SIMPLEIPC
1090  monitor(NULL,0);
1091 #ifdef PAGE_TEST
1092  mmEndStat();
1093 #endif
1096  {
1098  while(hh!=NULL)
1099  {
1100  //Print("close %s\n",hh->l->name);
1101  slPrepClose(hh->l);
1102  hh=(link_list)hh->next;
1103  }
1105 
1106  idhdl h = currPack->idroot;
1107  while(h != NULL)
1108  {
1109  if(IDTYP(h) == LINK_CMD)
1110  {
1111  idhdl hh=h->next;
1112  //Print("kill %s\n",IDID(h));
1113  killhdl(h, currPack);
1114  h = hh;
1115  }
1116  else
1117  {
1118  h = h->next;
1119  }
1120  }
1121  hh=ssiToBeClosed;
1122  while(hh!=NULL)
1123  {
1124  //Print("close %s\n",hh->l->name);
1125  slClose(hh->l);
1126  hh=ssiToBeClosed;
1127  }
1128  }
1129  if (!singular_in_batchmode)
1130  {
1131  if (i<=0)
1132  {
1133  if (TEST_V_QUIET)
1134  {
1135  if (i==0)
1136  printf("Auf Wiedersehen.\n");
1137  else
1138  printf("\n$Bye.\n");
1139  }
1140  //#ifdef sun
1141  // #ifndef __svr4__
1142  // _cleanup();
1143  // _exit(0);
1144  // #endif
1145  //#endif
1146  i=0;
1147  }
1148  else
1149  {
1150  printf("\nhalt %d\n",i);
1151  }
1152  }
1153  exit(i);
1154  }
1155 }
#define TEST_V_QUIET
Definition: options.h:127
volatile BOOLEAN m2_end_called
Definition: misc_ip.cc:1067
#define FALSE
Definition: auxiliary.h:140
#define TRUE
Definition: auxiliary.h:144
FILE * File_Profiling
Definition: fevoices.cc:38
Definition: idrec.h:34
void monitor(void *F, int mode)
Definition: febase.cc:72
#define IDTYP(a)
Definition: ipid.h:118
sem_t * semaphore[SIPC_MAX_SEMAPHORES]
Definition: semaphore.c:29
BOOLEAN singular_in_batchmode
Definition: cntrlc.cc:72
int j
Definition: myNF.cc:70
void fe_reset_input_mode()
Definition: fereadl.c:826
int i
Definition: cfEzgcd.cc:123
idhdl next
Definition: idrec.h:38
Definition: tok.h:119
#define NULL
Definition: omList.c:10
void killhdl(idhdl h, package proot)
Definition: ipid.cc:372
package currPack
Definition: ipid.cc:63
#define SIPC_MAX_SEMAPHORES
Definition: simpleipc.h:10
int sem_acquired[SIPC_MAX_SEMAPHORES]
Definition: semaphore.c:30
static Poly * h
Definition: janet.cc:978
static FORCE_INLINE number mpz2number ( mpz_t  m)
static

Definition at line 47 of file misc_ip.cc.

47 { return mpz2number(m, coeffs_BIGINT); }
coeffs coeffs_BIGINT
Definition: ipid.cc:54
static FORCE_INLINE number mpz2number(mpz_t m)
Definition: misc_ip.cc:47
int m
Definition: cfEzgcd.cc:119
static FORCE_INLINE void number2mpz ( number  n,
mpz_t  m 
)
static

Definition at line 46 of file misc_ip.cc.

46 { number2mpz(n, coeffs_BIGINT, m); }
static FORCE_INLINE void number2mpz(number n, mpz_t m)
Definition: misc_ip.cc:46
coeffs coeffs_BIGINT
Definition: ipid.cc:54
int m
Definition: cfEzgcd.cc:119
void omSingOutOfMemoryFunc ( )

Definition at line 1160 of file misc_ip.cc.

1161  {
1162  fprintf(stderr, "\nSingular error: no more memory\n");
1163  omPrintStats(stderr);
1164  m2_end(14);
1165  /* should never get here */
1166  exit(1);
1167  }
void m2_end(int i)
Definition: misc_ip.cc:1069
void omPrintStats(FILE *fd)
Definition: omStats.c:114
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, with corresponding multiplicities.

The method finds all prime factors with multiplicities. If a positive bound is given, then only the prime factors <= pBound are being found. In this case, there may remain an unfactored portion m of n. Also, when n is negative, m will contain the sign. If n is zero, m will be zero. The method returns a list L filled with three entries: L[1] a list; L[1][i] contains the i-th prime factor of |n| as int or bigint (sorted in ascending order), L[2] a list; L[2][i] contains the multiplicity of L[1, i] in |n| as int L[3] contains the remainder m as int or bigint, depending on the size,

We thus have: n = L[1][1]^L[2][1] * ... * L[1][k]^L[2][k] * L[3], where k is the number of mutually distinct prime factors (<= a provided non- zero bound). Note that for n = 0, L[1] and L[2] will be emtpy lists and L[3] will be zero.

Returns
the factorisation data in a SINGULAR-internal list
Parameters
[in]nthe bigint > 0 to be factorised
[in]pBoundbound on the prime factors seeked

Definition at line 333 of file misc_ip.cc.

334 {
335  int i;
336  int index=0;
337  mpz_t nn; number2mpz(n, nn);
338  lists primes = (lists)omAllocBin(slists_bin); primes->Init(1000);
339  int* multiplicities = (int*)omAlloc0(1000*sizeof(int));
340  int positive=1;
341 
342  if (!n_IsZero(n, coeffs_BIGINT))
343  {
344  if (!n_GreaterZero(n, coeffs_BIGINT))
345  {
346  positive=-1;
347  mpz_neg(nn,nn);
348  }
349  factor_gmp(nn,primes,multiplicities,index,pBound);
350  }
351 
352  lists primesL = (lists)omAllocBin(slists_bin);
353  primesL->Init(index);
354  for (i = 0; i < index; i++)
355  {
356  primesL->m[i].rtyp = primes->m[i].rtyp;
357  primesL->m[i].data = primes->m[i].data;
358  primes->m[i].rtyp=0;
359  primes->m[i].data=NULL;
360  }
361  primes->Clean(NULL);
362 
363  lists multiplicitiesL = (lists)omAllocBin(slists_bin);
364  multiplicitiesL->Init(index);
365  for (i = 0; i < index; i++)
366  {
367  multiplicitiesL->m[i].rtyp = INT_CMD;
368  multiplicitiesL->m[i].data = (void*)(long)multiplicities[i];
369  }
370  omFree(multiplicities);
371 
373  L->Init(3);
374  if (positive==-1) mpz_neg(nn,nn);
375  L->m[0].rtyp = LIST_CMD; L->m[0].data = (void*)primesL;
376  L->m[1].rtyp = LIST_CMD; L->m[1].data = (void*)multiplicitiesL;
377  setListEntry(L, 2, nn);
378 
379  mpz_clear(nn);
380 
381  return L;
382 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
static void factor_gmp(mpz_t t, lists primes, int *multiplicities, int &index, unsigned long bound)
Definition: misc_ip.cc:303
sleftv * m
Definition: lists.h:45
static FORCE_INLINE void number2mpz(number n, mpz_t m)
Definition: misc_ip.cc:46
Definition: tok.h:98
Definition: lists.h:22
void setListEntry(lists L, int index, mpz_t n)
Definition: misc_ip.cc:50
static unsigned short primes[]
primes, primes_len: used to step through possible extensions
coeffs coeffs_BIGINT
Definition: ipid.cc:54
void * data
Definition: subexpr.h:89
#define omFree(addr)
Definition: omAllocDecl.h:261
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:465
static int index(p_Length length, p_Ord ord)
Definition: p_Procs_Impl.h:592
INLINE_THIS void Init(int l=0)
Definition: lists.h:66
#define NULL
Definition: omList.c:10
slists * lists
Definition: mpr_numeric.h:146
int rtyp
Definition: subexpr.h:92
void Clean(ring r=currRing)
Definition: lists.h:25
Definition: tok.h:120
omBin slists_bin
Definition: lists.cc:23
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
#define omAlloc0(size)
Definition: omAllocDecl.h:211
void setListEntry ( lists  L,
int  index,
mpz_t  n 
)

Definition at line 50 of file misc_ip.cc.

51 { /* assumes n > 0 */
52  /* try to fit nn into an int: */
53  if (mpz_size1(n)<=1)
54  {
55  int ui=(int)mpz_get_si(n);
56  if ((((ui<<3)>>3)==ui)
57  && (mpz_cmp_si(n,(long)ui)==0))
58  {
59  L->m[index].rtyp = INT_CMD; L->m[index].data = (void*)(long)ui;
60  return;
61  }
62  }
63  number nn = mpz2number(n);
64  L->m[index].rtyp = BIGINT_CMD; L->m[index].data = (void*)nn;
65 }
sleftv * m
Definition: lists.h:45
Definition: tok.h:98
Definition: tok.h:42
static FORCE_INLINE number mpz2number(mpz_t m)
Definition: misc_ip.cc:47
void * data
Definition: subexpr.h:89
static int index(p_Length length, p_Ord ord)
Definition: p_Procs_Impl.h:592
#define mpz_size1(A)
Definition: si_gmp.h:12
int rtyp
Definition: subexpr.h:92
void setListEntry_ui ( lists  L,
int  index,
unsigned long  ui 
)

Definition at line 67 of file misc_ip.cc.

68 { /* assumes n > 0 */
69  /* try to fit nn into an int: */
70  int i=(int)ui;
71  if ((((unsigned long)i)==ui) && (((i<<3)>>3)==i))
72  {
73  L->m[index].rtyp = INT_CMD; L->m[index].data = (void*)(long)i;
74  }
75  else
76  {
77  number nn = n_Init(ui, coeffs_BIGINT);
78  L->m[index].rtyp = BIGINT_CMD; L->m[index].data = (void*)nn;
79  }
80 }
sleftv * m
Definition: lists.h:45
Definition: tok.h:98
Definition: tok.h:42
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
coeffs coeffs_BIGINT
Definition: ipid.cc:54
void * data
Definition: subexpr.h:89
int i
Definition: cfEzgcd.cc:123
static int index(p_Length length, p_Ord ord)
Definition: p_Procs_Impl.h:592
int rtyp
Definition: subexpr.h:92
BOOLEAN setOption ( leftv  res,
leftv  v 
)

Definition at line 575 of file misc_ip.cc.

576 {
577  const char *n;
578  do
579  {
580  if (v->Typ()==STRING_CMD)
581  {
582  n=(const char *)v->CopyD(STRING_CMD);
583  }
584  else
585  {
586  if (v->name==NULL)
587  return TRUE;
588  if (v->rtyp==0)
589  {
590  n=v->name;
591  v->name=NULL;
592  }
593  else
594  {
595  n=omStrDup(v->name);
596  }
597  }
598 
599  int i;
600 
601  if(strcmp(n,"get")==0)
602  {
603  intvec *w=new intvec(2);
604  (*w)[0]=si_opt_1;
605  (*w)[1]=si_opt_2;
606  res->rtyp=INTVEC_CMD;
607  res->data=(void *)w;
608  goto okay;
609  }
610  if(strcmp(n,"set")==0)
611  {
612  if((v->next!=NULL)
613  &&(v->next->Typ()==INTVEC_CMD))
614  {
615  v=v->next;
616  intvec *w=(intvec*)v->Data();
617  si_opt_1=(*w)[0];
618  si_opt_2=(*w)[1];
619 #if 0
622 #ifdef HAVE_RINGS
624 #endif
625  ) {
627  }
628 #endif
629  goto okay;
630  }
631  }
632  if(strcmp(n,"none")==0)
633  {
634  si_opt_1=0;
635  si_opt_2=0;
636  goto okay;
637  }
638  for (i=0; (i==0) || (optionStruct[i-1].setval!=0); i++)
639  {
640  if (strcmp(n,optionStruct[i].name)==0)
641  {
642  if (optionStruct[i].setval & validOpts)
643  {
645  // optOldStd disables redthrough
646  if (optionStruct[i].setval == Sy_bit(OPT_OLDSTD))
648  }
649  else
650  Warn("cannot set option");
651 #if 0
654 #ifdef HAVE_RINGS
656 #endif
657  ) {
659  }
660 #endif
661  goto okay;
662  }
663  else if ((strncmp(n,"no",2)==0)
664  && (strcmp(n+2,optionStruct[i].name)==0))
665  {
666  if (optionStruct[i].setval & validOpts)
667  {
669  }
670  else
671  Warn("cannot clear option");
672  goto okay;
673  }
674  }
675  for (i=0; (i==0) || (verboseStruct[i-1].setval!=0); i++)
676  {
677  if (strcmp(n,verboseStruct[i].name)==0)
678  {
680  #ifdef YYDEBUG
681  #if YYDEBUG
682  /*debugging the bison grammar --> grammar.cc*/
683  extern int yydebug;
684  if (BVERBOSE(V_YACC)) yydebug=1;
685  else yydebug=0;
686  #endif
687  #endif
688  goto okay;
689  }
690  else if ((strncmp(n,"no",2)==0)
691  && (strcmp(n+2,verboseStruct[i].name)==0))
692  {
694  #ifdef YYDEBUG
695  #if YYDEBUG
696  /*debugging the bison grammar --> grammar.cc*/
697  extern int yydebug;
698  if (BVERBOSE(V_YACC)) yydebug=1;
699  else yydebug=0;
700  #endif
701  #endif
702  goto okay;
703  }
704  }
705  Werror("unknown option `%s`",n);
706  okay:
707  if (currRing != NULL)
708  currRing->options = si_opt_1 & TEST_RINGDEP_OPTS;
709  omFree((ADDRESS)n);
710  v=v->next;
711  } while (v!=NULL);
712 
713  // set global variable to show memory usage
714  extern int om_sing_opt_show_mem;
715  if (BVERBOSE(V_SHOW_MEM)) om_sing_opt_show_mem = 1;
716  else om_sing_opt_show_mem = 0;
717 
718  return FALSE;
719 }
unsigned si_opt_1
Definition: options.c:5
#define FALSE
Definition: auxiliary.h:140
const struct soptionStruct optionStruct[]
Definition: misc_ip.cc:516
#define OPT_OLDSTD
Definition: options.h:81
#define TRUE
Definition: auxiliary.h:144
void * ADDRESS
Definition: auxiliary.h:161
unsigned setval
Definition: ipid.h:154
unsigned resetval
Definition: ipid.h:155
int Typ()
Definition: subexpr.cc:976
#define Sy_bit(x)
Definition: options.h:30
BITSET validOpts
Definition: kstd1.cc:70
static BOOLEAN rField_has_simple_inverse(const ring r)
Definition: ring.h:494
void * data
Definition: subexpr.h:89
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
#define V_SHOW_MEM
Definition: options.h:41
#define TEST_OPT_INTSTRATEGY
Definition: options.h:105
Definition: intvec.h:14
const char * name
Definition: subexpr.h:88
#define omFree(addr)
Definition: omAllocDecl.h:261
int i
Definition: cfEzgcd.cc:123
const struct soptionStruct verboseStruct[]
Definition: misc_ip.cc:546
leftv next
Definition: subexpr.h:87
#define OPT_INTSTRATEGY
Definition: options.h:87
#define BVERBOSE(a)
Definition: options.h:33
CanonicalForm test
Definition: cfModGcd.cc:4037
char name(const Variable &v)
Definition: variable.h:95
#define V_YACC
Definition: options.h:42
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:434
#define NULL
Definition: omList.c:10
int yydebug
Definition: grammar.cc:1791
const CanonicalForm & w
Definition: facAbsFact.cc:55
int rtyp
Definition: subexpr.h:92
void * Data()
Definition: subexpr.cc:1118
#define OPT_REDTHROUGH
Definition: options.h:77
#define TEST_RINGDEP_OPTS
Definition: options.h:95
unsigned si_opt_2
Definition: options.c:6
void Werror(const char *fmt,...)
Definition: reporter.cc:199
void * CopyD(int t)
Definition: subexpr.cc:676
#define Warn
Definition: emacs.cc:80
#define omStrDup(s)
Definition: omAllocDecl.h:263
char* showOption ( )

Definition at line 721 of file misc_ip.cc.

722 {
723  int i;
724  BITSET tmp;
725 
726  StringSetS("//options:");
727  if ((si_opt_1!=0)||(si_opt_2!=0))
728  {
729  tmp=si_opt_1;
730  if(tmp)
731  {
732  for (i=0; optionStruct[i].setval!=0; i++)
733  {
734  if (optionStruct[i].setval & tmp)
735  {
736  StringAppend(" %s",optionStruct[i].name);
737  tmp &=optionStruct[i].resetval;
738  }
739  }
740  for (i=0; i<32; i++)
741  {
742  if (tmp & Sy_bit(i)) StringAppend(" %d",i);
743  }
744  }
745  tmp=si_opt_2;
746  if (tmp)
747  {
748  for (i=0; verboseStruct[i].setval!=0; i++)
749  {
750  if (verboseStruct[i].setval & tmp)
751  {
752  StringAppend(" %s",verboseStruct[i].name);
753  tmp &=verboseStruct[i].resetval;
754  }
755  }
756  for (i=1; i<32; i++)
757  {
758  if (tmp & Sy_bit(i)) StringAppend(" %d",i+32);
759  }
760  }
761  return StringEndS();
762  }
763  StringAppendS(" none");
764  return StringEndS();
765 }
unsigned si_opt_1
Definition: options.c:5
const struct soptionStruct optionStruct[]
Definition: misc_ip.cc:516
unsigned setval
Definition: ipid.h:154
unsigned resetval
Definition: ipid.h:155
char * StringEndS()
Definition: reporter.cc:151
#define BITSET
Definition: structs.h:17
#define Sy_bit(x)
Definition: options.h:30
void StringSetS(const char *st)
Definition: reporter.cc:128
void StringAppendS(const char *st)
Definition: reporter.cc:107
#define StringAppend
Definition: emacs.cc:82
int i
Definition: cfEzgcd.cc:123
const struct soptionStruct verboseStruct[]
Definition: misc_ip.cc:546
char name(const Variable &v)
Definition: variable.h:95
unsigned si_opt_2
Definition: options.c:6
void siInit ( char *  name)

Definition at line 1212 of file misc_ip.cc.

1213 {
1214 // factory default settings: -----------------------------------------------
1215  On(SW_USE_EZGCD);
1217  //On(SW_USE_FF_MOD_GCD);
1218  On(SW_USE_EZGCD_P);
1219  On(SW_USE_QGCD);
1220  Off(SW_USE_NTL_SORT); // may be changed by an command line option
1222 
1223 // memory initialization: -----------------------------------------------
1224  om_Opts.OutOfMemoryFunc = omSingOutOfMemoryFunc;
1225 #ifndef OM_NDEBUG
1226 #ifndef __OPTIMIZE__
1227  om_Opts.ErrorHook = dErrorBreak;
1228 #else
1229  om_Opts.Keep = 0; /* !OM_NDEBUG, __OPTIMIZE__*/
1230 #endif
1231 #else
1232  om_Opts.Keep = 0; /* OM_NDEBUG */
1233 #endif
1234  omInitInfo();
1235 
1236 // options ---------------------------------------------------------------
1237  si_opt_1=0;
1238 // interpreter tables etc.: -----------------------------------------------
1239  memset(&sLastPrinted,0,sizeof(sleftv));
1241 
1242  extern int iiInitArithmetic(); iiInitArithmetic(); // iparith.cc
1243 
1244  basePack=(package)omAlloc0(sizeof(*basePack));
1246  idhdl h;
1247  h=enterid("Top", 0, PACKAGE_CMD, &IDROOT, TRUE);
1248  IDPACKAGE(h)->language = LANG_TOP;
1249  IDPACKAGE(h)=basePack;
1250  currPackHdl=h;
1251  basePackHdl=h;
1252 
1253  coeffs_BIGINT = nInitChar(n_Q,(void*)1);
1254 
1255 #if 1
1256  // def HAVE_POLYEXTENSIONS
1257  if(TRUE)
1258  {
1260  assume(type == n_algExt);
1261 
1262  type = nRegister(n_transExt, ntInitChar);
1263  assume(type == n_transExt);
1264 
1265  (void)type;
1266  }
1267 #endif
1268 
1269 // random generator: -----------------------------------------------
1270  int t=initTimer();
1271  if (t==0) t=1;
1272  initRTimer();
1273  siSeed=t;
1274  factoryseed(t);
1275  siRandomStart=t;
1276  feOptSpec[FE_OPT_RANDOM].value = (void*) ((long)siRandomStart);
1277 
1278 // ressource table: ----------------------------------------------------
1279  // Don't worry: ifdef OM_NDEBUG, then all these calls are undef'ed
1280  // hack such that all shared' libs in the bindir are loaded correctly
1282 
1283 // singular links: --------------------------------------------------
1284  slStandardInit();
1285  myynest=0;
1286 // semapohore 0 -----------------------------------------------------
1287  int cpus=2;
1288  int cpu_n;
1289  #ifdef _SC_NPROCESSORS_ONLN
1290  if ((cpu_n=sysconf(_SC_NPROCESSORS_ONLN))>cpus) cpus=cpu_n;
1291  #elif defined(_SC_NPROCESSORS_CONF)
1292  if ((cpu_n=sysconf(_SC_NPROCESSORS_CONF))>cpus) cpus=cpu_n;
1293  #endif
1294  feSetOptValue(FE_OPT_CPUS, cpus);
1295 
1296 #ifdef SINGULAR_4_1
1297 // default coeffs
1298  {
1299  idhdl h;
1300  h=enterid(omStrDup("QQ"),0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1301  IDDATA(h)=(char*)nInitChar(n_Q,NULL);
1302  h=enterid(omStrDup("ZZ"),0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1303  IDDATA(h)=(char*)nInitChar(n_Z,NULL);
1304  //h=enterid(omStrDup("RR"),0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1305  //IDDATA(h)=(char*)nInitChar(n_R,NULL);
1306  //h=enterid(omStrDup("CC"),0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1307  //IDDATA(h)=(char*)nInitChar(n_long_C,NULL);
1309  if (t!=n_unknown)
1310  {
1311  h=enterid(omStrDup("AE"),0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1312  IDDATA(h)=(char*)nInitChar(t,NULL);
1313  }
1315  if (t!=n_unknown)
1316  {
1317  h=enterid(omStrDup("QAE"),0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1318  IDDATA(h)=(char*)nInitChar(t,NULL);
1319  }
1321  if (n_pAE!=n_unknown)
1322  {
1323  iiAddCproc("kernel","pAE",FALSE,ii_pAE_init);
1324  }
1325  #ifdef HAVE_FLINT
1327  if (t!=n_unknown)
1328  {
1329  h=enterid(omStrDup("flint_poly_Q"),0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1330  IDDATA(h)=(char*)nInitChar(t,NULL);
1331  }
1333  if (n_FlintZn!=n_unknown)
1334  {
1335  iiAddCproc("kernel","flintZ",FALSE,ii_FlintZn_init);
1336  }
1337  #endif
1338  }
1339 #endif
1340 // setting routines for PLURAL QRINGS:
1341  nc_NF=k_NF;
1347 // loading standard.lib -----------------------------------------------
1348  if (! feOptValue(FE_OPT_NO_STDLIB))
1349  {
1350  BITSET save1,save2;
1351  SI_SAVE_OPT(save1,save2);
1352  si_opt_2 &= ~Sy_bit(V_LOAD_LIB);
1353  iiLibCmd(omStrDup("standard.lib"), TRUE,TRUE,TRUE);
1354  SI_RESTORE_OPT(save1,save2);
1355  }
1356  errorreported = 0;
1357 }
BBA_Proc sca_mora
Definition: old.gring.cc:76
int iiInitArithmetic()
initialisation of arithmetic structured data
Definition: iparith.cc:9034
BOOLEAN flintQ_InitChar(coeffs cf, void *infoStruct)
Definition: flintcf_Q.cc:564
poly k_NF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce, const ring _currRing)
NOTE: this is just a wrapper which sets currRing for the actual kNF call.
Definition: kstd1.cc:2919
ip_package * package
Definition: structs.h:46
void omSingOutOfMemoryFunc()
Definition: misc_ip.cc:1160
unsigned si_opt_1
Definition: options.c:5
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
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
static void * feOptValue(feOptIndex opt)
Definition: feOpt.h:40
void Off(int sw)
switches
idhdl currPackHdl
Definition: ipid.cc:61
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
#define FALSE
Definition: auxiliary.h:140
static n_coeffType n_FlintZn
Definition: misc_ip.cc:1187
#define V_LOAD_LIB
Definition: options.h:45
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
BOOLEAN n_QAEInitChar(coeffs r, void *)
Definition: OPAEQ.cc:336
#define IDROOT
Definition: ipid.h:20
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
void * value
Definition: fegetopt.h:93
const char * feSetOptValue(feOptIndex opt, char *optarg)
Definition: feOpt.cc:153
void feInitResources(const char *argv0)
Definition: feResource.cc:170
void WerrorS(const char *s)
Definition: feFopen.cc:24
void initRTimer()
Definition: timer.cc:158
static n_coeffType n_pAE
Definition: misc_ip.cc:1171
idhdl basePackHdl
Definition: ipid.cc:62
#define BITSET
Definition: structs.h:17
coeffs coeffs_BIGINT
Definition: ipid.cc:54
#define Sy_bit(x)
Definition: options.h:30
BOOLEAN iiLibCmd(char *newlib, BOOLEAN autoexport, BOOLEAN tellerror, BOOLEAN force)
Definition: iplib.cc:803
Definition: idrec.h:34
omOpts_t om_Opts
Definition: omOpts.c:11
BBA_Proc gnc_gr_bba
Definition: old.gring.cc:73
#define IDPACKAGE(a)
Definition: ipid.h:138
int myynest
Definition: febase.cc:46
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:259
Definition: tok.h:59
#define SI_RESTORE_OPT(A, B)
Definition: options.h:22
void omInitInfo()
Definition: omStats.c:17
n_coeffType nRegister(n_coeffType n, cfInitCharProc p)
Definition: numbers.cc:518
BBA_Proc sca_bba
Definition: old.gring.cc:75
BBA_Proc gnc_gr_mora
Definition: old.gring.cc:74
#define assume(x)
Definition: mod2.h:405
static BOOLEAN ii_FlintZn_init(leftv res, leftv a)
Definition: misc_ip.cc:1188
struct fe_option feOptSpec[]
only used if HAVE_RINGS is defined: ?
Definition: coeffs.h:42
void On(int sw)
switches
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
static const int SW_USE_CHINREM_GCD
set to 1 to use modular gcd over Z
Definition: cf_defs.h:38
short errorreported
Definition: feFopen.cc:23
BOOLEAN flintZn_InitChar(coeffs cf, void *infoStruct)
Definition: flintcf_Zn.cc:470
BOOLEAN n_pAEInitChar(coeffs r, void *p)
Definition: OPAEp.cc:351
n_coeffType
Definition: coeffs.h:27
char name(const Variable &v)
Definition: variable.h:95
#define NULL
Definition: omList.c:10
int siSeed
Definition: sirandom.c:29
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic ...
Definition: coeffs.h:35
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
package currPack
Definition: ipid.cc:63
int rtyp
Definition: subexpr.h:92
#define SI_SAVE_OPT(A, B)
Definition: options.h:19
sleftv sLastPrinted
Definition: subexpr.cc:55
int initTimer()
Definition: timer.cc:69
NF_Proc nc_NF
Definition: old.gring.cc:72
int iiAddCproc(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
Definition: iplib.cc:993
#define IDDATA(a)
Definition: ipid.h:125
BBA_Proc sca_gr_bba
Definition: old.gring.cc:77
unsigned si_opt_2
Definition: options.c:6
static Poly * h
Definition: janet.cc:978
static BOOLEAN ii_pAE_init(leftv res, leftv a)
Definition: misc_ip.cc:1172
#define NONE
Definition: tok.h:220
void dErrorBreak()
Definition: dError.cc:141
#define omAlloc0(size)
Definition: omAllocDecl.h:211
void(* factoryError)(const char *s)
Definition: cf_util.cc:75
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 omStrDup(s)
Definition: omAllocDecl.h:263
void singular_example ( char *  str)

Definition at line 439 of file misc_ip.cc.

440 {
441  assume(str!=NULL);
442  char *s=str;
443  while (*s==' ') s++;
444  char *ss=s;
445  while (*ss!='\0') ss++;
446  while (*ss<=' ')
447  {
448  *ss='\0';
449  ss--;
450  }
451  idhdl h=IDROOT->get(s,myynest);
452  if ((h!=NULL) && (IDTYP(h)==PROC_CMD))
453  {
454  char *lib=iiGetLibName(IDPROC(h));
455  if((lib!=NULL)&&(*lib!='\0'))
456  {
457  Print("// proc %s from lib %s\n",s,lib);
458  s=iiGetLibProcBuffer(IDPROC(h), 2);
459  if (s!=NULL)
460  {
461  if (strlen(s)>5)
462  {
463  iiEStart(s,IDPROC(h));
464  omFree((ADDRESS)s);
465  return;
466  }
467  else omFree((ADDRESS)s);
468  }
469  }
470  }
471  else
472  {
473  char sing_file[MAXPATHLEN];
474  FILE *fd=NULL;
475  char *res_m=feResource('m', 0);
476  if (res_m!=NULL)
477  {
478  sprintf(sing_file, "%s/%s.sing", res_m, s);
479  fd = feFopen(sing_file, "r");
480  }
481  if (fd != NULL)
482  {
483 
484  int old_echo = si_echo;
485  int length, got;
486  char* s;
487 
488  fseek(fd, 0, SEEK_END);
489  length = ftell(fd);
490  fseek(fd, 0, SEEK_SET);
491  s = (char*) omAlloc((length+20)*sizeof(char));
492  got = fread(s, sizeof(char), length, fd);
493  fclose(fd);
494  if (got != length)
495  {
496  Werror("Error while reading file %s", sing_file);
497  }
498  else
499  {
500  s[length] = '\0';
501  strcat(s, "\n;return();\n\n");
502  si_echo = 2;
503  iiEStart(s, NULL);
504  si_echo = old_echo;
505  }
506  omFree(s);
507  }
508  else
509  {
510  Werror("no example for %s", str);
511  }
512  }
513 }
int status int fd
Definition: si_signals.h:59
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define MAXPATHLEN
Definition: omRet2Info.c:22
#define Print
Definition: emacs.cc:83
static char * feResource(feResourceConfig config, int warn)
Definition: feResource.cc:258
#define IDROOT
Definition: ipid.h:20
void * ADDRESS
Definition: auxiliary.h:161
#define omAlloc(size)
Definition: omAllocDecl.h:210
Definition: idrec.h:34
int myynest
Definition: febase.cc:46
#define IDTYP(a)
Definition: ipid.h:118
#define omFree(addr)
Definition: omAllocDecl.h:261
#define assume(x)
Definition: mod2.h:405
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
Definition: feFopen.cc:47
BOOLEAN iiEStart(char *example, procinfo *pi)
Definition: iplib.cc:655
#define IDPROC(a)
Definition: ipid.h:139
#define SEEK_END
Definition: mod2.h:121
#define NULL
Definition: omList.c:10
char * iiGetLibName(procinfov pi)
Definition: iplib.cc:102
#define SEEK_SET
Definition: mod2.h:125
char * iiGetLibProcBuffer(procinfo *pi, int part)
Definition: iplib.cc:211
static Poly * h
Definition: janet.cc:978
void Werror(const char *fmt,...)
Definition: reporter.cc:199
int si_echo
Definition: febase.cc:41
int singular_fstat ( int  fd,
struct stat *  buf 
)

Definition at line 1054 of file misc_ip.cc.

1055 {
1056  return si_fstat(fd,buf);
1057 }
int status int fd
Definition: si_signals.h:59
int status int void * buf
Definition: si_signals.h:59
char* versionString ( )

Definition at line 778 of file misc_ip.cc.

779 {
780  StringSetS("");
781  StringAppend("Singular for %s version %s (%d, %d bit) %s #%s",
782  S_UNAME, VERSION, // SINGULAR_VERSION,
783  SINGULAR_VERSION, SIZEOF_VOIDP*8, VERSION_DATE, GIT_VERSION);
784  StringAppendS("\nwith\n\t");
785 
786 #if defined(mpir_version)
787  StringAppend("MPIR(%s)~GMP(%s),", mpir_version, gmp_version);
788 #elif defined(gmp_version)
789  // #if defined (__GNU_MP_VERSION) && defined (__GNU_MP_VERSION_MINOR)
790  // StringAppend("GMP(%d.%d),",__GNU_MP_VERSION,__GNU_MP_VERSION_MINOR);
791  StringAppend("GMP(%s),", gmp_version);
792 #endif
793 #ifdef HAVE_NTL
794 #include <NTL/version.h>
795  StringAppend("NTL(%s),",NTL_VERSION);
796 #endif
797 
798 #ifdef HAVE_FLINT
799  StringAppend("FLINT(%s),",version);
800 #endif
801  StringAppend("factory(%s),\n\t", factoryVersion);
802 #if defined(HAVE_DYN_RL)
804  StringAppendS("no input,");
805  else if (fe_fgets_stdin==fe_fgets)
806  StringAppendS("fgets,");
808  StringAppendS("dynamic readline,");
809  #ifdef HAVE_FEREAD
811  StringAppendS("emulated readline,");
812  #endif
813  else
814  StringAppendS("unknown fgets method,");
815 #else
816  #if defined(HAVE_READLINE) && !defined(FEREAD)
817  StringAppendS("static readline,");
818  #else
819  #ifdef HAVE_FEREAD
820  StringAppendS("emulated readline,");
821  #else
822  StringAppendS("fgets,");
823  #endif
824  #endif
825 #endif
826 #ifdef HAVE_PLURAL
827  StringAppendS("Plural,");
828 #endif
829 #ifdef HAVE_DBM
830  StringAppendS("DBM,\n\t");
831 #else
832  StringAppendS("\n\t");
833 #endif
834 #ifdef HAVE_DYNAMIC_LOADING
835  StringAppendS("dynamic modules,");
836 #endif
837  if (p_procs_dynamic) StringAppendS("dynamic p_Procs,");
838 #if YYDEBUG
839  StringAppendS("YYDEBUG=1,");
840 #endif
841 #ifdef HAVE_ASSUME
842  StringAppendS("ASSUME,");
843 #endif
844 #ifdef MDEBUG
845  StringAppend("MDEBUG=%d,",MDEBUG);
846 #endif
847 #ifdef OM_CHECK
848  StringAppend("OM_CHECK=%d,",OM_CHECK);
849 #endif
850 #ifdef OM_TRACK
851  StringAppend("OM_TRACK=%d,",OM_TRACK);
852 #endif
853 #ifdef OM_NDEBUG
854  StringAppendS("OM_NDEBUG,");
855 #endif
856 #ifdef SING_NDEBUG
857  StringAppendS("SING_NDEBUG,");
858 #endif
859 #ifdef PDEBUG
860  StringAppendS("PDEBUG,");
861 #endif
862 #ifdef KDEBUG
863  StringAppendS("KDEBUG,");
864 #endif
865 #ifdef __OPTIMIZE__
866  StringAppendS("CC:OPTIMIZE,");
867 #endif
868 #ifdef __OPTIMIZE_SIZE__
869  StringAppendS("CC:OPTIMIZE_SIZE,");
870 #endif
871 #ifdef __NO_INLINE__
872  StringAppendS("CC:NO_INLINE,");
873 #endif
874 #ifdef HAVE_EIGENVAL
875  StringAppendS("eigenvalues,");
876 #endif
877 #ifdef HAVE_GMS
878  StringAppendS("Gauss-Manin system,");
879 #endif
880 #ifdef HAVE_RATGRING
881  StringAppendS("ratGB,");
882 #endif
883  StringAppend("random=%d\n",siRandomStart);
884 
885 #define SI_SHOW_BUILTIN_MODULE(name) StringAppend(" %s", #name);
886  StringAppendS("built-in modules: {");
888  StringAppendS("}\n");
889 #undef SI_SHOW_BUILTIN_MODULE
890 
891  StringAppend("AC_CONFIGURE_ARGS = %s,\n"
892  "CC = %s,FLAGS : %s,\n"
893  "CXX = %s,FLAGS : %s,\n"
894  "DEFS : %s,CPPFLAGS : %s,\n"
895  "LDFLAGS : %s,LIBS : %s "
896 #ifdef __GNUC__
897  "(ver: " __VERSION__ ")"
898 #endif
899  "\n",AC_CONFIGURE_ARGS, CC,CFLAGS, CXX,CXXFLAGS, DEFS,CPPFLAGS, LDFLAGS,LIBS);
902  StringAppendS("\n");
903  return StringEndS();
904 }
#define OM_CHECK
Definition: omalloc_debug.c:15
char *(* fe_fgets_stdin)(const char *pr, char *s, int size)
Definition: feread.cc:33
void feStringAppendResources(int warn)
Definition: reporter.cc:415
const BOOLEAN p_procs_dynamic
#define SINGULAR_VERSION
Definition: mod2.h:94
char * fe_fgets(const char *pr, char *s, int size)
Definition: feread.cc:310
char * fe_fgets_dummy(const char *, char *, int)
Definition: feread.cc:418
int siRandomStart
Definition: cntrlc.cc:103
SI_FOREACH_BUILTIN(SI_GET_BUILTIN_MOD_INIT0)}
char * StringEndS()
Definition: reporter.cc:151
void feStringAppendBrowsers(int warn)
Definition: fehelp.cc:352
#define MDEBUG
Definition: mod2.h:196
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
void StringAppendS(const char *st)
Definition: reporter.cc:107
#define StringAppend
Definition: emacs.cc:82
#define version
Definition: libparse.cc:1260
#define OM_TRACK
Definition: omalloc_debug.c:10
#define VERSION
Definition: mod2.h:21
#define SI_SHOW_BUILTIN_MODULE(name)
const char factoryVersion[]
extern const char factoryVersion[];
char * fe_fgets_stdin_drl(const char *pr, char *s, int size)
Definition: feread.cc:270

Variable Documentation

unsigned add[] = {4, 2, 4, 2, 4, 6, 2, 6}
static

Definition at line 83 of file misc_ip.cc.

volatile BOOLEAN m2_end_called = FALSE

Definition at line 1067 of file misc_ip.cc.

n_coeffType n_FlintZn =n_unknown
static

Definition at line 1187 of file misc_ip.cc.

n_coeffType n_pAE =n_unknown
static

Definition at line 1171 of file misc_ip.cc.

const struct soptionStruct optionStruct[]
Initial value:
=
{
{"prot", Sy_bit(OPT_PROT), ~Sy_bit(OPT_PROT) },
{"redSB", Sy_bit(OPT_REDSB), ~Sy_bit(OPT_REDSB) },
{"teach", Sy_bit(OPT_DEBUG), ~Sy_bit(OPT_DEBUG) },
{"fastHC", Sy_bit(OPT_FASTHC), ~Sy_bit(OPT_FASTHC) },
{"degBound", Sy_bit(OPT_DEGBOUND), ~Sy_bit(OPT_DEGBOUND) },
{"redTail", Sy_bit(OPT_REDTAIL), ~Sy_bit(OPT_REDTAIL) },
{"weightM", Sy_bit(OPT_WEIGHTM), ~Sy_bit(OPT_WEIGHTM) },
{"ne", 0, 0 }
}
#define OPT_REDSB
Definition: options.h:71
#define OPT_PROT
Definition: options.h:70
#define OPT_INFREDTAIL
Definition: options.h:89
#define OPT_MULTBOUND
Definition: options.h:84
#define OPT_NO_SYZ_MINIM
Definition: options.h:78
#define OPT_OLDSTD
Definition: options.h:81
#define Sy_bit(x)
Definition: options.h:30
#define OPT_REDTAIL
Definition: options.h:86
#define OPT_NOT_BUCKETS
Definition: options.h:72
#define OPT_NOT_SUGAR
Definition: options.h:73
#define OPT_STAIRCASEBOUND
Definition: options.h:83
#define OPT_SUGARCRIT
Definition: options.h:75
#define OPT_INTSTRATEGY
Definition: options.h:87
#define OPT_DEBUG
Definition: options.h:76
#define OPT_WEIGHTM
Definition: options.h:92
#define OPT_REDTHROUGH
Definition: options.h:77
#define OPT_DEGBOUND
Definition: options.h:85
#define OPT_NOTREGULARITY
Definition: options.h:91
#define OPT_INTERRUPT
Definition: options.h:74
#define OPT_FASTHC
Definition: options.h:80
#define OPT_RETURN_SB
Definition: options.h:79

Definition at line 516 of file misc_ip.cc.

const struct soptionStruct verboseStruct[]
Initial value:
=
{
{"yacc", Sy_bit(V_YACC), ~Sy_bit(V_YACC) },
{"redefine", Sy_bit(V_REDEFINE), ~Sy_bit(V_REDEFINE) },
{"reading", Sy_bit(V_READING), ~Sy_bit(V_READING) },
{"loadLib", Sy_bit(V_LOAD_LIB), ~Sy_bit(V_LOAD_LIB) },
{"debugLib", Sy_bit(V_DEBUG_LIB), ~Sy_bit(V_DEBUG_LIB) },
{"loadProc", Sy_bit(V_LOAD_PROC), ~Sy_bit(V_LOAD_PROC) },
{"defRes", Sy_bit(V_DEF_RES), ~Sy_bit(V_DEF_RES) },
{"Imap", Sy_bit(V_IMAP), ~Sy_bit(V_IMAP) },
{"prompt", Sy_bit(V_PROMPT), ~Sy_bit(V_PROMPT) },
{"length", Sy_bit(V_LENGTH), ~Sy_bit(V_LENGTH) },
{"notWarnSB",Sy_bit(V_NSB), ~Sy_bit(V_NSB) },
{"contentSB",Sy_bit(V_CONTENTSB), ~Sy_bit(V_CONTENTSB) },
{"findMonomials",Sy_bit(V_FINDMONOM),~Sy_bit(V_FINDMONOM)},
{"coefStrat",Sy_bit(V_COEFSTRAT), ~Sy_bit(V_COEFSTRAT)},
{"qringNF", Sy_bit(V_QRING), ~Sy_bit(V_QRING)},
{"ne", 0, 0 }
}
#define V_COEFSTRAT
Definition: options.h:59
#define V_LENGTH
Definition: options.h:61
#define V_LOAD_LIB
Definition: options.h:45
#define V_DEF_RES
Definition: options.h:48
#define V_FINDMONOM
Definition: options.h:58
#define V_DEBUG_LIB
Definition: options.h:46
#define V_INTERSECT_ELIM
Definition: options.h:64
#define Sy_bit(x)
Definition: options.h:30
#define V_QRING
Definition: options.h:40
#define V_SHOW_USE
Definition: options.h:50
#define V_SHOW_MEM
Definition: options.h:41
#define V_CONTENTSB
Definition: options.h:54
#define V_UPTORADICAL
Definition: options.h:57
#define V_READING
Definition: options.h:44
#define V_LOAD_PROC
Definition: options.h:47
#define V_ALLWARN
Definition: options.h:63
#define V_YACC
Definition: options.h:42
#define V_PROMPT
Definition: options.h:52
#define V_NSB
Definition: options.h:53
#define V_CANCELUNIT
Definition: options.h:55
#define V_INTERSECT_SYZ
Definition: options.h:65
#define V_REDEFINE
Definition: options.h:43
#define V_MODPSOLVSB
Definition: options.h:56
#define V_IMAP
Definition: options.h:51

Definition at line 546 of file misc_ip.cc.