My Project
Loading...
Searching...
No Matches
misc_ip.cc File Reference

This file provides miscellaneous functionality. More...

#include "kernel/mod2.h"
#include "kernel/oswrapper/vspace.h"
#include "misc/sirandom.h"
#include "omalloc/omalloc.h"
#include "misc/mylimits.h"
#include "reporter/si_signals.h"
#include "factory/factory.h"
#include "coeffs/si_gmp.h"
#include "coeffs/coeffs.h"
#include "coeffs/flintcf_Q.h"
#include "coeffs/flintcf_Qrat.h"
#include "coeffs/flintcf_Zn.h"
#include "coeffs/rmodulon.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 "misc/distrib.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 <NTL/version.h>
#include <flint/flint.h>

Go to the source code of this file.

Macros

#define PLURAL_INTERNAL_DECLARATIONS   1
 
#define SI_SHOW_BUILTIN_MODULE(name)
 

Functions

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.
 
void singular_example (char *str)
 
BOOLEAN setOption (leftv res, leftv v)
 
char * showOption ()
 
char * versionString ()
 
int singular_fstat (int fd, struct stat *buf)
 
void m2_end (int i)
 
void omSingOutOfMemoryFunc ()
 
static BOOLEAN ii_FlintZn_init (leftv res, leftv a)
 
static BOOLEAN ii_FlintQ_init (leftv res, leftv a)
 
int flint_mod_init (SModulFunctions *psModulFunctions)
 
static BOOLEAN iiFloat (leftv res, leftv pnn)
 
static BOOLEAN iiCrossProd (leftv res, leftv args)
 
static void callWerrorS (const char *s)
 
void siInit (char *name)
 

Variables

STATIC_VAR 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_VAR n_coeffType n_FlintZn =n_unknown
 
STATIC_VAR n_coeffType n_FlintQ =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

◆ PLURAL_INTERNAL_DECLARATIONS

#define PLURAL_INTERNAL_DECLARATIONS   1

Definition at line 14 of file misc_ip.cc.

◆ SI_SHOW_BUILTIN_MODULE

#define SI_SHOW_BUILTIN_MODULE ( name)
Value:
StringAppend(" %s", #name);
#define StringAppend
Definition emacs.cc:79
int name
New type name for int.

Function Documentation

◆ callWerrorS()

static void callWerrorS ( const char * s)
static

Definition at line 1360 of file misc_ip.cc.

1360{ WerrorS(s); }
const CanonicalForm int s
Definition facAbsFact.cc:51
void WerrorS(const char *s)
Definition feFopen.cc:24

◆ factor_gmp()

static void factor_gmp ( mpz_t t,
lists primes,
int * multiplicities,
int & index,
unsigned long bound )
static

Definition at line 328 of file misc_ip.cc.

329{
330 unsigned int division_limit;
331
332 if (mpz_sgn (t) == 0)
333 return;
334
335 /* Set the trial division limit according the size of t. */
336 division_limit = mpz_sizeinbase (t, 2);
337 if (division_limit > 1000)
338 division_limit = 1000 * 1000;
339 else
340 division_limit = division_limit * division_limit;
341
342 if (factor_using_division (t, division_limit,primes,multiplicities,index,bound))
343 {
344 if (mpz_cmp_ui (t, 1) != 0)
345 {
346 if (mpz_probab_prime_p (t, 10))
347 {
349 multiplicities[index++] = 1;
350 mpz_set_ui(t,1);
351 }
352 else
353 factor_using_pollard_rho (t, 1L, primes,multiplicities,index);
354 }
355 }
356}
static CanonicalForm bound(const CFMatrix &M)
Definition cf_linsys.cc:460
STATIC_VAR unsigned short primes[]
primes, primes_len: used to step through possible extensions
static int factor_using_division(mpz_t t, unsigned int limit, lists primes, int *multiplicities, int &index, unsigned long bound)
Definition misc_ip.cc:110
static void factor_using_pollard_rho(mpz_t n, unsigned long a, lists primes, int *multiplicities, int &index)
Definition misc_ip.cc:205
void setListEntry(lists L, int index, mpz_t n)
Definition misc_ip.cc:75
static int index(p_Length length, p_Ord ord)

◆ factor_using_division()

static int factor_using_division ( mpz_t t,
unsigned int limit,
lists primes,
int * multiplicities,
int & index,
unsigned long bound )
static

Definition at line 110 of file misc_ip.cc.

111{
112 mpz_t q, r;
113 unsigned long int f;
114 int ai;
115 unsigned *addv = add;
116 unsigned int failures;
117 int bound_not_reached=1;
118
119 mpz_init (q);
120 mpz_init (r);
121
122 f = mpz_scan1 (t, 0);
123 mpz_div_2exp (t, t, f);
124 if (f>0)
125 {
127 multiplicities[index++] = f;
128 }
129
130 f=0;
131 loop
132 {
133 mpz_tdiv_qr_ui (q, r, t, 3);
134 if (mpz_sgn1 (r) != 0)
135 break;
136 mpz_set (t, q);
137 f++;
138 }
139 if (f>0)
140 {
142 multiplicities[index++] = f;
143 }
144 f=0;
145 loop
146 {
147 mpz_tdiv_qr_ui (q, r, t, 5);
148 if (mpz_sgn1 (r) != 0)
149 break;
150 mpz_set (t, q);
151 f++;
152 }
153 if (f>0)
154 {
156 multiplicities[index++] = f;
157 }
158
159 failures = 0;
160 f = 7;
161 ai = 0;
162 unsigned long last_f=0;
163 while (mpz_cmp_ui (t, 1) != 0)
164 {
165 mpz_tdiv_qr_ui (q, r, t, f);
166 if (mpz_sgn1 (r) != 0)
167 {
168 f += addv[ai];
169 if (mpz_cmp_ui (t, f) < 0)
170 break;
171 ai = (ai + 1) & 7;
172 failures++;
173 if (failures > limit)
174 break;
175 if ((bound!=0) && (f>bound))
176 {
177 bound_not_reached=0;
178 break;
179 }
180 }
181 else
182 {
183 mpz_swap (t, q);
184 if (f!=last_f)
185 {
187 multiplicities[index]++;
188 index++;
189 }
190 else
191 {
192 multiplicities[index-1]++;
193 }
194 last_f=f;
195 failures = 0;
196 }
197 }
198
199 mpz_clear (q);
200 mpz_clear (r);
201 //printf("bound=%d,f=%d,failures=%d, reached=%d\n",bound,f,failures,bound_not_reached);
202 return bound_not_reached;
203}
FILE * f
Definition checklibs.c:9
void setListEntry_ui(lists L, int index, unsigned long ui)
Definition misc_ip.cc:92
STATIC_VAR unsigned add[]
Definition misc_ip.cc:108
#define mpz_sgn1(A)
Definition si_gmp.h:18
#define loop
Definition structs.h:71

◆ factor_using_pollard_rho()

static void factor_using_pollard_rho ( mpz_t n,
unsigned long a,
lists primes,
int * multiplicities,
int & index )
static

Definition at line 205 of file misc_ip.cc.

206{
207 mpz_t x, x1, y, P;
208 mpz_t t1, t2;
209 mpz_t last_f;
210 unsigned long long k, l, i;
211
212 mpz_init (t1);
213 mpz_init (t2);
214 mpz_init_set_ui (last_f, 0);
215 mpz_init_set_ui (y, 2);
216 mpz_init_set_ui (x, 2);
217 mpz_init_set_ui (x1, 2);
218 mpz_init_set_ui (P, 1);
219 k = 1;
220 l = 1;
221
222 while (mpz_cmp_ui (n, 1) != 0)
223 {
224 loop
225 {
226 do
227 {
228 mpz_mul (t1, x, x);
229 mpz_mod (x, t1, n);
230 mpz_add_ui (x, x, a);
231 mpz_sub (t1, x1, x);
232 mpz_mul (t2, P, t1);
233 mpz_mod (P, t2, n);
234
235 if (k % 32 == 1)
236 {
237 mpz_gcd (t1, P, n);
238 if (mpz_cmp_ui (t1, 1) != 0)
239 goto factor_found;
240 mpz_set (y, x);
241 }
242 }
243 while (--k != 0);
244
245 mpz_gcd (t1, P, n);
246 if (mpz_cmp_ui (t1, 1) != 0)
247 goto factor_found;
248
249 mpz_set (x1, x);
250 k = l;
251 l = 2 * l;
252 for (i = 0; i < k; i++)
253 {
254 mpz_mul (t1, x, x);
255 mpz_mod (x, t1, n);
256 mpz_add_ui (x, x, a);
257 }
258 mpz_set (y, x);
259 }
260
261 factor_found:
262 do
263 {
264 mpz_mul (t1, y, y);
265 mpz_mod (y, t1, n);
266 mpz_add_ui (y, y, a);
267 mpz_sub (t1, x1, y);
268 mpz_gcd (t1, t1, n);
269 }
270 while (mpz_cmp_ui (t1, 1) == 0);
271
272 mpz_divexact (n, n, t1); /* divide by t1, before t1 is overwritten */
273
274 if (!mpz_probab_prime_p (t1, 10))
275 {
276 do
277 {
278 mp_limb_t a_limb;
279 mpn_random (&a_limb, (mp_size_t) 1);
280 a = a_limb;
281 }
282 while (a == 0);
283
284 factor_using_pollard_rho (t1, a, primes,multiplicities,index);
285 }
286 else
287 {
288 if (mpz_cmp(t1,last_f)==0)
289 {
290 multiplicities[index-1]++;
291 }
292 else
293 {
294 mpz_set(last_f,t1);
296 multiplicities[index++] = 1;
297 }
298 }
299 mpz_mod (x, x, n);
300 mpz_mod (x1, x1, n);
301 mpz_mod (y, y, n);
302 if (mpz_probab_prime_p (n, 10))
303 {
304 if (mpz_cmp(n,last_f)==0)
305 {
306 multiplicities[index-1]++;
307 }
308 else
309 {
310 mpz_set(last_f,n);
312 multiplicities[index++] = 1;
313 }
314 mpz_set_ui(n,1);
315 break;
316 }
317 }
318
319 mpz_clear (P);
320 mpz_clear (t2);
321 mpz_clear (t1);
322 mpz_clear (x1);
323 mpz_clear (x);
324 mpz_clear (y);
325 mpz_clear (last_f);
326}
int l
Definition cfEzgcd.cc:100
int i
Definition cfEzgcd.cc:132
int k
Definition cfEzgcd.cc:99
Variable x
Definition cfModGcd.cc:4090
const CanonicalForm int const CFList const Variable & y
Definition facAbsFact.cc:53

◆ flint_mod_init()

int flint_mod_init ( SModulFunctions * psModulFunctions)

Definition at line 1272 of file misc_ip.cc.

1273{
1274 package save=currPack;
1277 if (n_FlintQ!=n_unknown)
1278 {
1279 iiAddCproc("kernel","flintQp",FALSE,ii_FlintQ_init);
1281 }
1282#if __FLINT_RELEASE >= 20503
1283 iiAddCproc("kernel","flintQ",FALSE,ii_FlintQrat_init);
1285#endif
1287 if (n_FlintZn!=n_unknown)
1288 {
1289 iiAddCproc("kernel","flintZn",FALSE,ii_FlintZn_init);
1291 }
1292 currPack=save;
1293 return MAX_TOK;
1294}
#define FALSE
Definition auxiliary.h:97
@ n_unknown
Definition coeffs.h:28
BOOLEAN flintQ_InitChar(coeffs cf, void *infoStruct)
Definition flintcf_Q.cc:636
coeffs flintQInitCfByName(char *s, n_coeffType n)
Definition flintcf_Q.cc:608
BOOLEAN flintZn_InitChar(coeffs cf, void *infoStruct)
coeffs flintZnInitCfByName(char *s, n_coeffType n)
VAR package basePack
Definition ipid.cc:56
VAR package currPack
Definition ipid.cc:55
int iiAddCproc(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
Definition iplib.cc:1073
static BOOLEAN ii_FlintQ_init(leftv res, leftv a)
Definition misc_ip.cc:1227
STATIC_VAR n_coeffType n_FlintQ
Definition misc_ip.cc:1211
static BOOLEAN ii_FlintZn_init(leftv res, leftv a)
Definition misc_ip.cc:1213
STATIC_VAR n_coeffType n_FlintZn
Definition misc_ip.cc:1210
void nRegisterCfByName(cfInitCfByNameProc p, n_coeffType n)
Definition numbers.cc:624
n_coeffType nRegister(n_coeffType n, cfInitCharProc p)
Definition numbers.cc:583
@ MAX_TOK
Definition tok.h:220

◆ ii_FlintQ_init()

static BOOLEAN ii_FlintQ_init ( leftv res,
leftv a )
static

Definition at line 1227 of file misc_ip.cc.

1228{
1229 const short t[]={1,STRING_CMD};
1230 if (iiCheckTypes(a,t,1))
1231 {
1232 char* p;
1233 p=(char*)a->Data();
1234 res->rtyp=CRING_CMD;
1235 res->data=(void*)nInitChar(n_FlintQ,(void*)p);
1236 return FALSE;
1237 }
1238 return TRUE;
1239}
#define TRUE
Definition auxiliary.h:101
int p
Definition cfModGcd.cc:4086
void * Data()
Definition subexpr.cc:1192
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition numbers.cc:406
CanonicalForm res
Definition facAbsFact.cc:60
BOOLEAN iiCheckTypes(leftv args, const short *type_list, int report)
check a list of arguemys against a given field of types return TRUE if the types match return FALSE (...
Definition ipshell.cc:6569
@ CRING_CMD
Definition tok.h:56
@ STRING_CMD
Definition tok.h:187

◆ ii_FlintZn_init()

static BOOLEAN ii_FlintZn_init ( leftv res,
leftv a )
static

Definition at line 1213 of file misc_ip.cc.

1214{
1215 const short t[]={2,INT_CMD,STRING_CMD};
1216 if (iiCheckTypes(a,t,1))
1217 {
1219 p.ch=(int)(long)a->Data();
1220 p.name=(char*)a->next->Data();
1221 res->rtyp=CRING_CMD;
1222 res->data=(void*)nInitChar(n_FlintZn,(void*)&p);
1223 return FALSE;
1224 }
1225 return TRUE;
1226}
leftv next
Definition subexpr.h:86
@ INT_CMD
Definition tok.h:96

◆ iiCrossProd()

static BOOLEAN iiCrossProd ( leftv res,
leftv args )
static

Definition at line 1326 of file misc_ip.cc.

1327{
1328 leftv h=args;
1329 coeffs *c=NULL;
1330 coeffs cf=NULL;
1331 int i=0;
1332 if (h==NULL) goto crossprod_error;
1333 while (h!=NULL)
1334 {
1335 if (h->Typ()!=CRING_CMD) goto crossprod_error;
1336 i++;
1337 h=h->next;
1338 }
1339 c=(coeffs*)omAlloc0((i+1)*sizeof(coeffs));
1340 h=args;
1341 i=0;
1342 while (h!=NULL)
1343 {
1344 c[i]=(coeffs)h->CopyD();
1345 i++;
1346 h=h->next;
1347 }
1349 res->data=cf;
1350 res->rtyp=CRING_CMD;
1351 return FALSE;
1352
1353 crossprod_error:
1354 WerrorS("expected `crossprod(coeffs, ...)`");
1355 return TRUE;
1356}
CanonicalForm cf
Definition cfModGcd.cc:4091
@ n_nTupel
n-tupel of cf: ZZ/p1,... ZZ/pn, R, long_R
Definition coeffs.h:42
STATIC_VAR Poly * h
Definition janet.cc:971
The main handler for Singular numbers which are suitable for Singular polynomials.
#define omAlloc0(size)
#define NULL
Definition omList.c:12
sleftv * leftv
Definition structs.h:53

◆ iiFloat()

static BOOLEAN iiFloat ( leftv res,
leftv pnn )
static

Definition at line 1297 of file misc_ip.cc.

1298{
1299 short float_len=3;
1300 short float_len2=SHORT_REAL_LENGTH;
1301 coeffs cf=NULL;
1302 if ((pnn!=NULL) && (pnn->Typ()==INT_CMD))
1303 {
1304 float_len=(int)(long)pnn->Data();
1305 float_len2=float_len;
1306 pnn=pnn->next;
1307 if ((pnn!=NULL) && (pnn->Typ()==INT_CMD))
1308 {
1309 float_len2=(int)(long)pnn->Data();
1310 pnn=pnn->next;
1311 }
1312 }
1313 if (float_len2 <= (short)SHORT_REAL_LENGTH)
1314 cf=nInitChar(n_R, NULL);
1315 else // longR or longC?
1316 {
1317 LongComplexInfo param;
1318 param.float_len = si_min (float_len, 32767);
1319 param.float_len2 = si_min (float_len2, 32767);
1320 cf = nInitChar(n_long_R, (void*)&param);
1321 }
1322 res->rtyp=CRING_CMD;
1323 res->data=cf;
1324 return cf==NULL;
1325}
static int si_min(const int a, const int b)
Definition auxiliary.h:126
int Typ()
Definition subexpr.cc:1048
@ n_R
single prescision (6,6) real numbers
Definition coeffs.h:31
@ n_long_R
real floating point (GMP) numbers
Definition coeffs.h:33
short float_len2
additional char-flags, rInit
Definition coeffs.h:109
short float_len
additional char-flags, rInit
Definition coeffs.h:108
#define SHORT_REAL_LENGTH
Definition numbers.h:57

◆ m2_end()

void m2_end ( int i)

Definition at line 1102 of file misc_ip.cc.

1103{
1104 if (!m2_end_called)
1105 {
1107 EXTERN_VAR FILE* File_Log;
1110 if (File_Log!=NULL)
1111 {
1112 fclose(File_Log);
1113 File_Log=NULL;
1114 if (File_Log_written==FALSE) // remove empty logs
1115 {
1116 int pid=getpid();
1117 char buf[20];
1118 snprintf(buf,20,"/tmp/sing_log.%d",pid);
1119 remove(buf);
1120 }
1121 }
1123#ifdef HAVE_SIMPLEIPC
1124 for (int j = SIPC_MAX_SEMAPHORES-1; j >= 0; j--)
1125 {
1126 if (semaphore[j] != NULL)
1127 {
1128 while (sem_acquired[j] > 0)
1129 {
1130#if PORTABLE_SEMAPHORES
1131 sem_post(semaphore[j]->sig);
1132#else
1133 sem_post(semaphore[j]);
1134#endif
1135 sem_acquired[j]--;
1136 }
1137 }
1138 }
1139#endif // HAVE_SIMPLEIPC
1140 monitor(NULL,0);
1142 {
1144 while(hh!=NULL)
1145 {
1146 //Print("close %s\n",hh->l->name);
1147 slPrepClose(hh->l);
1148 hh=(link_list)hh->next;
1149 }
1151
1152 idhdl h = currPack->idroot;
1153 while(h != NULL)
1154 {
1155 if(IDTYP(h) == LINK_CMD)
1156 {
1157 idhdl hh=h->next;
1158 //Print("kill %s\n",IDID(h));
1159 killhdl(h, currPack);
1160 h = hh;
1161 }
1162 else
1163 {
1164 h = h->next;
1165 }
1166 }
1167 hh=ssiToBeClosed;
1168 while(hh!=NULL)
1169 {
1170 //Print("close %s\n",hh->l->name);
1171 slClose(hh->l);
1172 hh=ssiToBeClosed;
1173 }
1174 }
1175#ifdef PAGE_TEST
1176 mmEndStat();
1177#endif
1180 {
1181 if (TEST_V_QUIET)
1182 {
1183 if (i==0)
1184 printf("Auf Wiedersehen.\n");
1185 }
1186 if (i>0)
1187 {
1188 printf("\nhalt %d\n",i);
1189 }
1190 }
1191 if (i>=0) exit(i);
1192 else _exit(0);
1193 }
1194}
int BOOLEAN
Definition auxiliary.h:88
VAR BOOLEAN singular_in_batchmode
Definition cntrlc.cc:62
int j
Definition facHensel.cc:110
void monitor(void *F, int mode)
Definition febase.cc:68
void fe_reset_input_mode()
Definition fereadl.c:831
VAR FILE * File_Profiling
Definition fevoices.cc:32
VAR BOOLEAN File_Log_written
Definition fevoices.cc:34
VAR FILE * File_Log
Definition fevoices.cc:33
#define EXTERN_VAR
Definition globaldefs.h:6
void killhdl(idhdl h, package proot)
Definition ipid.cc:391
#define IDTYP(a)
Definition ipid.h:119
volatile BOOLEAN m2_end_called
Definition misc_ip.cc:1100
#define TEST_V_QUIET
Definition options.h:135
idrec * idhdl
Definition ring.h:22
VAR sipc_sem_t * semaphore[SIPC_MAX_SEMAPHORES]
Definition semaphore.c:24
VAR int sem_acquired[SIPC_MAX_SEMAPHORES]
Definition semaphore.c:25
int status int void * buf
Definition si_signals.h:69
#define SIPC_MAX_SEMAPHORES
Definition simpleipc.h:10
@ LINK_CMD
Definition tok.h:117

◆ omSingOutOfMemoryFunc()

void omSingOutOfMemoryFunc ( )

Definition at line 1199 of file misc_ip.cc.

1200 {
1201 fprintf(stderr, "\nSingular error: no more memory\n");
1202 omPrintStats(stderr);
1203 m2_end(14);
1204 /* should never get here */
1205 exit(1);
1206 }
void m2_end(int i)
Definition misc_ip.cc:1102
#define omPrintStats(F)
Definition xalloc.h:231

◆ primeFactorisation()

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 empty 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 358 of file misc_ip.cc.

359{
360 int i;
361 int index=0;
362 mpz_t nn; number2mpz(n, coeffs_BIGINT, nn);
363 lists primes = (lists)omAllocBin(slists_bin); primes->Init(1000);
364 int* multiplicities = (int*)omAlloc0(1000*sizeof(int));
365 int positive=1;
366
367 if (!n_IsZero(n, coeffs_BIGINT))
368 {
370 {
371 positive=-1;
372 mpz_neg(nn,nn);
373 }
374 factor_gmp(nn,primes,multiplicities,index,pBound);
375 }
376
377 lists primesL = (lists)omAllocBin(slists_bin);
378 primesL->Init(index);
379 for (i = 0; i < index; i++)
380 {
381 primesL->m[i].rtyp = primes->m[i].rtyp;
382 primesL->m[i].data = primes->m[i].data;
383 primes->m[i].rtyp=0;
384 primes->m[i].data=NULL;
385 }
386 primes->Clean(NULL);
387
388 lists multiplicitiesL = (lists)omAllocBin(slists_bin);
389 multiplicitiesL->Init(index);
390 for (i = 0; i < index; i++)
391 {
392 multiplicitiesL->m[i].rtyp = INT_CMD;
393 multiplicitiesL->m[i].data = (void*)(long)multiplicities[i];
394 }
395 omFree(multiplicities);
396
398 L->Init(3);
399 if (positive==-1) mpz_neg(nn,nn);
400 L->m[0].rtyp = LIST_CMD; L->m[0].data = (void*)primesL;
401 L->m[1].rtyp = LIST_CMD; L->m[1].data = (void*)multiplicitiesL;
402 setListEntry(L, 2, nn);
403
404 mpz_clear(nn);
405
406 return L;
407}
int rtyp
Definition subexpr.h:91
void * data
Definition subexpr.h:88
sleftv * m
Definition lists.h:46
INLINE_THIS void Init(int l=0)
static FORCE_INLINE void number2mpz(number n, coeffs c, mpz_t m)
Definition coeffs.h:984
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),...
Definition coeffs.h:498
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition coeffs.h:468
VAR omBin slists_bin
Definition lists.cc:23
static void factor_gmp(mpz_t t, lists primes, int *multiplicities, int &index, unsigned long bound)
Definition misc_ip.cc:328
slists * lists
#define omAllocBin(bin)
#define omFree(addr)
VAR coeffs coeffs_BIGINT
Definition polys.cc:14
@ LIST_CMD
Definition tok.h:118

◆ setListEntry()

void setListEntry ( lists L,
int index,
mpz_t n )

Definition at line 75 of file misc_ip.cc.

76{ /* assumes n > 0 */
77 /* try to fit nn into an int: */
78 if (mpz_size1(n)<=1)
79 {
80 int ui=(int)mpz_get_si(n);
81 if ((((ui<<3)>>3)==ui)
82 && (mpz_cmp_si(n,(long)ui)==0))
83 {
84 L->m[index].rtyp = INT_CMD; L->m[index].data = (void*)(long)ui;
85 return;
86 }
87 }
88 number nn = mpz2number(n, coeffs_BIGINT);
89 L->m[index].rtyp = BIGINT_CMD; L->m[index].data = (void*)nn;
90}
static FORCE_INLINE number mpz2number(mpz_t m, coeffs c)
Definition coeffs.h:985
#define mpz_size1(A)
Definition si_gmp.h:17
@ BIGINT_CMD
Definition tok.h:38

◆ setListEntry_ui()

void setListEntry_ui ( lists L,
int index,
unsigned long ui )

Definition at line 92 of file misc_ip.cc.

93{ /* assumes n > 0 */
94 /* try to fit nn into an int: */
95 int i=(int)ui;
96 if ((((unsigned long)i)==ui) && (((i<<3)>>3)==i))
97 {
98 L->m[index].rtyp = INT_CMD; L->m[index].data = (void*)(long)i;
99 }
100 else
101 {
102 number nn = n_Init(ui, coeffs_BIGINT);
103 L->m[index].rtyp = BIGINT_CMD; L->m[index].data = (void*)nn;
104 }
105}
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

◆ setOption()

BOOLEAN setOption ( leftv res,
leftv v )

Definition at line 570 of file misc_ip.cc.

571{
572 const char *n;
573 do
574 {
575 if (v->Typ()==STRING_CMD)
576 {
577 n=(const char *)v->CopyD(STRING_CMD);
578 }
579 else
580 {
581 if (v->name==NULL)
582 return TRUE;
583 if (v->rtyp==0)
584 {
585 n=v->name;
586 v->name=NULL;
587 }
588 else
589 {
590 n=omStrDup(v->name);
591 }
592 }
593
594 int i;
595
596 if(strcmp(n,"get")==0)
597 {
598 intvec *w=new intvec(2);
599 (*w)[0]=si_opt_1;
600 (*w)[1]=si_opt_2;
601 res->rtyp=INTVEC_CMD;
602 res->data=(void *)w;
603 goto okay;
604 }
605 if(strcmp(n,"set")==0)
606 {
607 if((v->next!=NULL)
608 &&(v->next->Typ()==INTVEC_CMD))
609 {
610 v=v->next;
611 intvec *w=(intvec*)v->Data();
612 si_opt_1=(*w)[0];
613 si_opt_2=(*w)[1];
614#if 0
618 ) {
620 }
621#endif
622 goto okay;
623 }
624 }
625 if(strcmp(n,"none")==0)
626 {
627 si_opt_1=0;
628 si_opt_2=0;
629 goto okay;
630 }
631 for (i=0; (i==0) || (optionStruct[i-1].setval!=0); i++)
632 {
633 if (strcmp(n,optionStruct[i].name)==0)
634 {
635 if (optionStruct[i].setval & validOpts)
636 {
637 si_opt_1 |= optionStruct[i].setval;
638 // optOldStd disables redthrough
639 if (optionStruct[i].setval == Sy_bit(OPT_OLDSTD))
641 }
642 else
643 WarnS("cannot set option");
644#if 0
648 ) {
650 }
651#endif
652 goto okay;
653 }
654 else if ((strncmp(n,"no",2)==0)
655 && (strcmp(n+2,optionStruct[i].name)==0))
656 {
657 if (optionStruct[i].setval & validOpts)
658 {
659 si_opt_1 &= optionStruct[i].resetval;
660 }
661 else
662 WarnS("cannot clear option");
663 goto okay;
664 }
665 }
666 for (i=0; (i==0) || (verboseStruct[i-1].setval!=0); i++)
667 {
668 if (strcmp(n,verboseStruct[i].name)==0)
669 {
670 si_opt_2 |= verboseStruct[i].setval;
671 #ifdef YYDEBUG
672 #if YYDEBUG
673 /*debugging the bison grammar --> grammar.cc*/
675 if (BVERBOSE(V_YACC)) yydebug=1;
676 else yydebug=0;
677 #endif
678 #endif
679 goto okay;
680 }
681 else if ((strncmp(n,"no",2)==0)
682 && (strcmp(n+2,verboseStruct[i].name)==0))
683 {
684 si_opt_2 &= verboseStruct[i].resetval;
685 #ifdef YYDEBUG
686 #if YYDEBUG
687 /*debugging the bison grammar --> grammar.cc*/
689 if (BVERBOSE(V_YACC)) yydebug=1;
690 else yydebug=0;
691 #endif
692 #endif
693 goto okay;
694 }
695 }
696 Werror("unknown option `%s`",n);
697 okay:
698 if (currRing != NULL)
701 v=v->next;
702 } while (v!=NULL);
703
704 // set global variable to show memory usage
706 else om_sing_opt_show_mem = 0;
707
708 return FALSE;
709}
void * ADDRESS
Definition auxiliary.h:120
CanonicalForm test
Definition cfModGcd.cc:4104
#define WarnS
Definition emacs.cc:78
const CanonicalForm & w
Definition facAbsFact.cc:51
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
int yydebug
Definition grammar.cc:1843
const struct soptionStruct verboseStruct[]
Definition misc_ip.cc:539
const struct soptionStruct optionStruct[]
Definition misc_ip.cc:508
VAR BITSET validOpts
Definition kstd1.cc:60
#define omStrDup(s)
#define omFreeBinAddr(addr)
int om_sing_opt_show_mem
VAR unsigned si_opt_2
Definition options.c:6
VAR unsigned si_opt_1
Definition options.c:5
#define OPT_INTSTRATEGY
Definition options.h:93
#define TEST_OPT_INTSTRATEGY
Definition options.h:112
#define BVERBOSE(a)
Definition options.h:35
#define V_SHOW_MEM
Definition options.h:43
#define V_YACC
Definition options.h:44
#define OPT_REDTHROUGH
Definition options.h:83
#define Sy_bit(x)
Definition options.h:31
#define TEST_RINGDEP_OPTS
Definition options.h:101
#define OPT_OLDSTD
Definition options.h:87
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
void Werror(const char *fmt,...)
Definition reporter.cc:189
static BOOLEAN rField_has_simple_inverse(const ring r)
Definition ring.h:554
#define rField_is_Ring(R)
Definition ring.h:491
@ INTVEC_CMD
Definition tok.h:101

◆ showOption()

char * showOption ( )

Definition at line 711 of file misc_ip.cc.

712{
713 int i;
714 BITSET tmp;
715
716 StringSetS("//options:");
717 if ((si_opt_1!=0)||(si_opt_2!=0))
718 {
719 tmp=si_opt_1;
720 if(tmp)
721 {
722 for (i=0; optionStruct[i].setval!=0; i++)
723 {
724 if (optionStruct[i].setval & tmp)
725 {
727 tmp &=optionStruct[i].resetval;
728 }
729 }
730 for (i=0; i<32; i++)
731 {
732 if (tmp & Sy_bit(i)) StringAppend(" %d",i);
733 }
734 }
735 tmp=si_opt_2;
736 if (tmp)
737 {
738 for (i=0; verboseStruct[i].setval!=0; i++)
739 {
740 if (verboseStruct[i].setval & tmp)
741 {
743 tmp &=verboseStruct[i].resetval;
744 }
745 }
746 for (i=1; i<32; i++)
747 {
748 if (tmp & Sy_bit(i)) StringAppend(" %d",i+32);
749 }
750 }
751 return StringEndS();
752 }
753 StringAppendS(" none");
754 return StringEndS();
755}
#define BITSET
Definition auxiliary.h:85
void StringSetS(const char *st)
Definition reporter.cc:128
void StringAppendS(const char *st)
Definition reporter.cc:107
char * StringEndS()
Definition reporter.cc:151

◆ siInit()

void siInit ( char * name)

Definition at line 1361 of file misc_ip.cc.

1362{
1363// memory initialization: -----------------------------------------------
1364 om_Opts.OutOfMemoryFunc = omSingOutOfMemoryFunc;
1365#ifndef OM_NDEBUG
1366#ifndef __OPTIMIZE__
1367 om_Opts.ErrorHook = dErrorBreak;
1368#else
1369 om_Opts.Keep = 0; /* !OM_NDEBUG, __OPTIMIZE__*/
1370#endif
1371#else
1372 om_Opts.Keep = 0; /* OM_NDEBUG */
1373#endif
1374 omInitInfo();
1375// factory
1376#ifndef HAVE_NTL
1377 extern void initPT();
1378 initPT();
1379#endif
1380// options ---------------------------------------------------------------
1381 si_opt_1=0;
1382// interpreter tables etc.: -----------------------------------------------
1383 memset(&sLastPrinted,0,sizeof(sleftv));
1384 sLastPrinted.rtyp=NONE;
1385
1386 extern int iiInitArithmetic(); iiInitArithmetic(); // iparith.cc
1387
1388 basePack=(package)omAlloc0(sizeof(*basePack));
1390 idhdl h;
1391 h=enterid("Top", 0, PACKAGE_CMD, &IDROOT, FALSE);
1393 IDPACKAGE(h)->language = LANG_TOP;
1394 currPackHdl=h;
1395 basePackHdl=h;
1396
1397 coeffs_BIGINT = nInitChar(n_Q,(void*)1);
1398
1399#if 1
1400 // def HAVE_POLYEXTENSIONS
1401 if(TRUE)
1402 {
1403 n_coeffType type;
1404 #ifdef SINGULAR_4_2
1406 assume(type == n_polyExt);
1407 #endif
1408
1409 type = nRegister(n_algExt, naInitChar);
1410 assume(type == n_algExt);
1411
1413 assume(type == n_transExt);
1414
1415 (void)type;
1416 }
1417#endif
1418
1419// random generator: -----------------------------------------------
1420 {
1421 int t=startTimer();
1422 if (t==0) t=1;
1423 initRTimer();
1424 siSeed=t;
1425 factoryseed(t);
1426 siRandomStart=t;
1427 feOptSpec[FE_OPT_RANDOM].value = (void*) ((long)siRandomStart);
1428 }
1429
1430// ressource table: ----------------------------------------------------
1431 // Don't worry: ifdef OM_NDEBUG, then all these calls are undef'ed
1432 // hack such that all shared' libs in the bindir are loaded correctly
1434
1435// singular links: --------------------------------------------------
1437 myynest=0;
1438// how many processes ? -----------------------------------------------------
1439 {
1440 int cpus=2;
1441 int cpu_n;
1442 #ifdef _SC_NPROCESSORS_ONLN
1443 if ((cpu_n=sysconf(_SC_NPROCESSORS_ONLN))>cpus) cpus=cpu_n;
1444 #elif defined(_SC_NPROCESSORS_CONF)
1445 if ((cpu_n=sysconf(_SC_NPROCESSORS_CONF))>cpus) cpus=cpu_n;
1446 #endif
1448 char *env_cpu=getenv("SINGULAR_CPUS");
1449 if (env_cpu!=NULL)
1450 {
1451 int t=atoi(env_cpu);
1452 if ((t>=0)&&(t<cpus)) cpus=t;
1453 }
1454 feSetOptValue(FE_OPT_CPUS, cpus);
1455// how many threads ? -----------------------------------------------------
1456 feSetOptValue(FE_OPT_THREADS, cpus);
1457 }
1458
1459// default coeffs
1460 {
1461 idhdl h;
1462 h=enterid("QQ",0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1463 IDDATA(h)=(char*)nInitChar(n_Q,NULL);
1464 h=enterid("ZZ",0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1465 IDDATA(h)=(char*)nInitChar(n_Z,NULL);
1467 iiAddCproc("kernel","crossprod",FALSE,iiCrossProd);
1468 iiAddCproc("kernel","Float",FALSE,iiFloat);
1469 //h=enterid("RR",0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1470 //IDDATA(h)=(char*)nInitChar(n_R,NULL);
1471 //h=enterid("CC",0/*level*/, CRING_CMD,&(basePack->idroot),FALSE /*init*/,FALSE /*search*/);
1472 //IDDATA(h)=(char*)nInitChar(n_long_C,NULL);
1473 }
1474// setting routines for PLURAL QRINGS:
1475// allowing to use libpolys without libSingular(kStd)
1476#ifdef HAVE_PLURAL
1477 nc_NF=k_NF;
1483#endif
1484// loading standard.lib -----------------------------------------------
1485 if (! feOptValue(FE_OPT_NO_STDLIB))
1486 {
1487 BITSET save1,save2;
1488 SI_SAVE_OPT(save1,save2);
1490 iiLibCmd("standard.lib", TRUE,TRUE,TRUE);
1491 SI_RESTORE_OPT(save1,save2);
1492 }
1493 // interpreter error handling
1494 #ifndef __CYGWIN__
1495 factoryError=callWerrorS; // to honour later changes of variable WerrorS
1496 #endif
1497 errorreported = 0;
1498}
BOOLEAN naInitChar(coeffs cf, void *infoStruct)
Initialize the coeffs object.
Definition algext.cc:1386
BOOLEAN n2pInitChar(coeffs cf, void *infoStruct)
Definition algext.cc:1640
void initPT()
void factoryseed(int s)
random seed initializer
Definition cf_random.cc:189
VAR void(* factoryError)(const char *s)
Definition cf_util.cc:80
Class used for (list of) interpreter objects.
Definition subexpr.h:83
VAR int siRandomStart
Definition cntrlc.cc:99
n_coeffType
Definition coeffs.h:27
@ n_polyExt
used to represent polys as coefficients
Definition coeffs.h:34
@ n_Q
rational (GMP) numbers
Definition coeffs.h:30
@ n_algExt
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
Definition coeffs.h:35
@ n_Zn
only used if HAVE_RINGS is defined
Definition coeffs.h:44
@ n_transExt
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition coeffs.h:38
@ n_Z
only used if HAVE_RINGS is defined
Definition coeffs.h:43
VAR short errorreported
Definition feFopen.cc:23
const char * feSetOptValue(feOptIndex opt, char *optarg)
Definition feOpt.cc:154
static void * feOptValue(feOptIndex opt)
Definition feOpt.h:40
EXTERN_VAR struct fe_option feOptSpec[]
Definition feOpt.h:17
void feInitResources(const char *argv0)
VAR int myynest
Definition febase.cc:41
char * getenv()
EXTERN_VAR BBA_Proc gnc_gr_bba
Definition gb_hack.h:10
EXTERN_VAR BBA_Proc gnc_gr_mora
Definition gb_hack.h:10
EXTERN_VAR BBA_Proc sca_gr_bba
Definition gb_hack.h:10
EXTERN_VAR NF_Proc nc_NF
Definition gb_hack.h:9
EXTERN_VAR BBA_Proc sca_mora
Definition gb_hack.h:10
EXTERN_VAR BBA_Proc sca_bba
Definition gb_hack.h:10
ideal k_gnc_gr_bba(const ideal F, const ideal Q, const intvec *, const bigintmat *, kStrategy strat, const ring _currRing)
Definition gr_kstd2.cc:1030
ideal k_gnc_gr_mora(const ideal F, const ideal Q, const intvec *, const bigintmat *, kStrategy strat, const ring _currRing)
Definition gr_kstd2.cc:1283
int iiInitArithmetic()
initialisation of arithmetic structured data
Definition iparith.cc:9953
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition ipid.cc:256
VAR idhdl currPackHdl
Definition ipid.cc:53
VAR idhdl basePackHdl
Definition ipid.cc:54
#define IDDATA(a)
Definition ipid.h:126
#define IDROOT
Definition ipid.h:19
#define IDPACKAGE(a)
Definition ipid.h:139
BOOLEAN iiLibCmd(const char *newlib, BOOLEAN autoexport, BOOLEAN tellerror, BOOLEAN force)
Definition iplib.cc:894
ideal k_sca_bba(const ideal F, const ideal Q, const intvec *, const bigintmat *, kStrategy strat, const ring _currRing)
Modified modern Sinuglar Buchberger's algorithm.
Definition sca.cc:368
ideal k_sca_gr_bba(const ideal F, const ideal Q, const intvec *, const bigintmat *, kStrategy strat, const ring _currRing)
Modified Plural's Buchberger's algorithmus.
Definition sca.cc:95
ideal k_sca_mora(const ideal F, const ideal Q, const intvec *, const bigintmat *, kStrategy strat, const ring _currRing)
Modified modern Sinuglar Mora's algorithm.
Definition sca.cc:885
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:3438
static BOOLEAN iiCrossProd(leftv res, leftv args)
Definition misc_ip.cc:1326
void omSingOutOfMemoryFunc()
Definition misc_ip.cc:1199
static BOOLEAN iiFloat(leftv res, leftv pnn)
Definition misc_ip.cc:1297
static void callWerrorS(const char *s)
Definition misc_ip.cc:1360
void dErrorBreak(void)
#define assume(x)
Definition mod2.h:389
omOpts_t om_Opts
Definition omOpts.c:13
#define SI_SAVE_OPT(A, B)
Definition options.h:20
#define V_LOAD_LIB
Definition options.h:47
#define SI_RESTORE_OPT(A, B)
Definition options.h:23
coeffs nrnInitCfByName(char *s, n_coeffType)
Definition rmodulon.cc:33
VAR int siSeed
Definition sirandom.c:30
ip_package * package
Definition structs.h:39
INST_VAR sleftv sLastPrinted
Definition subexpr.cc:46
@ LANG_TOP
Definition subexpr.h:22
int startTimer()
Definition timer.cc:66
void initRTimer()
Definition timer.cc:136
@ PACKAGE_CMD
Definition tok.h:150
#define NONE
Definition tok.h:223
BOOLEAN ntInitChar(coeffs cf, void *infoStruct)
Initialize the coeffs object.
Definition transext.cc:2636
#define omInitInfo()
Definition xalloc.h:228

◆ singular_example()

void singular_example ( char * str)

Definition at line 431 of file misc_ip.cc.

432{
433 assume(str!=NULL);
434 char *s=str;
435 while (*s==' ') s++;
436 char *ss=s;
437 while (*ss!='\0') ss++;
438 while (*ss<=' ')
439 {
440 *ss='\0';
441 ss--;
442 }
443 idhdl h=IDROOT->get_level(s,0);
444 if ((h!=NULL) && (IDTYP(h)==PROC_CMD))
445 {
446 char *lib=iiGetLibName(IDPROC(h));
447 if((lib!=NULL)&&(*lib!='\0'))
448 {
449 Print("// proc %s from lib %s\n",s,lib);
451 if (s!=NULL)
452 {
453 if (strlen(s)>5)
454 {
455 iiEStart(s,IDPROC(h));
456 omFree((ADDRESS)s);
457 return;
458 }
459 else omFree((ADDRESS)s);
460 }
461 }
462 }
463 else
464 {
465 char sing_file[MAXPATHLEN];
466 FILE *fd=NULL;
467 char *res_m=feResource('m', 0);
468 if (res_m!=NULL)
469 {
470 snprintf(sing_file,MAXPATHLEN, "%s/%s.sing", res_m, s);
471 fd = feFopen(sing_file, "r");
472 }
473 if (fd != NULL)
474 {
475
476 int old_echo = si_echo;
477 int length, got;
478 char* s;
479
480 fseek(fd, 0, SEEK_END);
481 length = ftell(fd);
482 fseek(fd, 0, SEEK_SET);
483 s = (char*) omAlloc((length+20)*sizeof(char));
484 got = fread(s, sizeof(char), length, fd);
485 fclose(fd);
486 if (got != length)
487 {
488 Werror("Error while reading file %s", sing_file);
489 }
490 else
491 {
492 s[length] = '\0';
493 strcat(s, "\n;return();\n\n");
494 si_echo = 2;
495 iiEStart(s, NULL);
496 si_echo = old_echo;
497 }
498 omFree(s);
499 }
500 else
501 {
502 Werror("no example for %s", str);
503 }
504 }
505}
#define Print
Definition emacs.cc:80
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
Definition feFopen.cc:47
static char * feResource(feResourceConfig config, int warn)
VAR int si_echo
Definition febase.cc:35
@ PROC_CMD
Definition grammar.cc:281
static BOOLEAN length(leftv result, leftv arg)
Definition interval.cc:257
#define IDPROC(a)
Definition ipid.h:140
BOOLEAN iiEStart(char *example, procinfo *pi)
Definition iplib.cc:763
char * iiGetLibProcBuffer(procinfo *pi, int part)
Definition iplib.cc:197
static char * iiGetLibName(const procinfov pi)
find the library of an proc
Definition ipshell.h:66
#define SEEK_SET
Definition mod2.h:115
#define SEEK_END
Definition mod2.h:111
char * str(leftv arg)
Definition shared.cc:699
#define omAlloc(size)
#define MAXPATHLEN
Definition omRet2Info.c:22
int status int fd
Definition si_signals.h:69

◆ singular_fstat()

int singular_fstat ( int fd,
struct stat * buf )

Definition at line 1087 of file misc_ip.cc.

1088{
1089 return si_fstat(fd,buf);
1090}

◆ versionString()

char * versionString ( )

Definition at line 772 of file misc_ip.cc.

773{
774 StringSetS("");
775 StringAppend("Singular for %s version %s (%d, %d bit) %s",
776 S_UNAME, VERSION, // SINGULAR_VERSION,
777 SINGULAR_VERSION, sizeof(void*)*8,
779 VERSION_DATE);
780#else
781 singular_date);
782#endif
783 StringAppendS("\nwith\n\t");
784
785#if defined(mpir_version)
786 StringAppend("MPIR(%s)~GMP(%s),", mpir_version, gmp_version);
787#elif defined(gmp_version)
788 // #if defined (__GNU_MP_VERSION) && defined (__GNU_MP_VERSION_MINOR)
789 // StringAppend("GMP(%d.%d),",__GNU_MP_VERSION,__GNU_MP_VERSION_MINOR);
790 StringAppend("GMP(%s),", gmp_version);
791#endif
792#ifdef HAVE_NTL
793 StringAppend("NTL(%s),",NTL_VERSION);
794#endif
795
796#ifdef HAVE_FLINT
797 StringAppend("FLINT(%s),",FLINT_VERSION);
798#endif
799// StringAppendS("factory(" FACTORYVERSION "),");
800 StringAppendS("\n\t");
801#ifndef HAVE_OMALLOC
802 StringAppendS("xalloc,");
803#else
804 StringAppendS("omalloc,");
805#endif
806#if defined(HAVE_DYN_RL)
808 StringAppendS("no input,");
809 else if (fe_fgets_stdin==fe_fgets)
810 StringAppendS("fgets,");
812 StringAppend("dynamic readline%d),",RL_VERSION_MAJOR);
813 #ifdef HAVE_FEREAD
815 StringAppendS("emulated readline,");
816 #endif
817 else
818 StringAppendS("unknown fgets method,");
819#else
820 #if defined(HAVE_READLINE) && !defined(FEREAD)
821 StringAppend("static readline(%d),",RL_VERSION_MAJOR);
822 #else
823 #ifdef HAVE_FEREAD
824 StringAppendS("emulated readline,");
825 #else
826 StringAppendS("fgets,");
827 #endif
828 #endif
829#endif
830#ifdef HAVE_PLURAL
831 StringAppendS("Plural,");
832#endif
833#ifdef HAVE_VSPACE
834 #if defined(__GNUC__) && (__GNUC__<9) &&!defined(__clang__)
835 StringAppendS("vspace(1),");
836 #else
837 StringAppendS("vspace(2),");
838 #endif
839#endif
840#ifdef HAVE_DBM
841 StringAppendS("DBM,\n\t");
842#else
843 StringAppendS("\n\t");
844#endif
845#ifdef HAVE_DYNAMIC_LOADING
846 StringAppendS("dynamic modules,");
847#endif
848#ifdef HAVE_DYNANIC_PPROCS
849 StringAppendS("dynamic p_Procs,");
850#endif
851#if YYDEBUG
852 StringAppendS("YYDEBUG=1,");
853#endif
854#ifdef MDEBUG
855 StringAppend("MDEBUG=%d,",MDEBUG);
856#endif
857#ifdef OM_CHECK
858 StringAppend("OM_CHECK=%d,",OM_CHECK);
859#endif
860#ifdef OM_TRACK
861 StringAppend("OM_TRACK=%d,",OM_TRACK);
862#endif
863#ifdef OM_NDEBUG
864 StringAppendS("OM_NDEBUG,");
865#endif
866#ifdef SING_NDEBUG
867 StringAppendS("SING_NDEBUG,");
868#endif
869#ifdef PDEBUG
870 StringAppendS("PDEBUG,");
871#endif
872#ifdef KDEBUG
873 StringAppendS("KDEBUG,");
874#endif
875#ifdef HAVE_SDB
876 StringAppendS("sdb,");
877#endif
878 StringAppendS("\n\t");
879#ifdef __OPTIMIZE__
880 StringAppendS("CC:OPTIMIZE,");
881#endif
882#ifdef __OPTIMIZE_SIZE__
883 StringAppendS("CC:OPTIMIZE_SIZE,");
884#endif
885#ifdef __NO_INLINE__
886 StringAppendS("CC:NO_INLINE,");
887#endif
888#ifdef HAVE_NTL
889 #ifdef NTL_AVOID_BRANCHING
890 #undef HAVE_GENERIC_ADD
891 #endif
892#endif
893#ifdef HAVE_GENERIC_ADD
894 StringAppendS("GenericAdd,");
895#else
896 StringAppendS("AvoidBranching,");
897#endif
898#ifdef HAVE_GENERIC_MULT
899 StringAppendS("GenericMult,");
900#else
901 StringAppendS("TableMult,");
902#endif
903#ifdef HAVE_INVTABLE
904 StringAppendS("invTable,");
905#else
906 StringAppendS("no invTable,");
907#endif
908 StringAppendS("\n\t");
909#ifdef HAVE_EIGENVAL
910 StringAppendS("eigenvalues,");
911#endif
912#ifdef HAVE_GMS
913 StringAppendS("Gauss-Manin system,");
914#endif
915#ifdef HAVE_RATGRING
916 StringAppendS("ratGB,");
917#endif
918 StringAppend("random=%d\n",siRandomStart);
919
920#define SI_SHOW_BUILTIN_MODULE(name) StringAppend(" %s", #name);
921 StringAppendS("built-in modules: {");
923 StringAppendS("}\n");
924#undef SI_SHOW_BUILTIN_MODULE
925
926 StringAppend("AC_CONFIGURE_ARGS = %s,\n"
927 "CC = %s,FLAGS : %s,\n"
928 "CXX = %s,FLAGS : %s,\n"
929 "DEFS : %s,CPPFLAGS : %s,\n"
930 "LDFLAGS : %s,LIBS : %s "
931#ifdef __GNUC__
932 "(ver: " __VERSION__ ")"
933#endif
934 "\n",AC_CONFIGURE_ARGS, CC,CFLAGS " " PTHREAD_CFLAGS,
935 CXX,CXXFLAGS " " PTHREAD_CFLAGS, DEFS,CPPFLAGS, LDFLAGS,
936 LIBS " " PTHREAD_LIBS);
939 StringAppendS("\n");
940 return StringEndS();
941}
#define MAKE_DISTRIBUTION
Definition distrib.h:1
#define VERSION
void feStringAppendBrowsers(int warn)
Definition fehelp.cc:341
char * fe_fgets_dummy(const char *, char *, int)
Definition feread.cc:455
char *(* fe_fgets_stdin)(const char *pr, char *s, int size)
Definition feread.cc:32
char * fe_fgets(const char *pr, char *s, int size)
Definition feread.cc:309
char * fe_fgets_stdin_drl(const char *pr, char *s, int size)
Definition feread.cc:269
char * fe_fgets_stdin_emu(const char *pr, char *s, int size)
Definition feread.cc:253
#define SI_SHOW_BUILTIN_MODULE(name)
#define SINGULAR_VERSION
Definition mod2.h:87
#define MDEBUG
Definition mod2.h:180
#define SI_FOREACH_BUILTIN(add)
Data for type_of_LIB to determine built-in modules, use add(name) to add built-in library to macro.
Definition mod_lib.h:17
#define OM_TRACK
#define OM_CHECK
void feStringAppendResources(int warn)
Definition reporter.cc:398

Variable Documentation

◆ add

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

Definition at line 108 of file misc_ip.cc.

108{4, 2, 4, 2, 4, 6, 2, 6};

◆ m2_end_called

volatile BOOLEAN m2_end_called = FALSE

Definition at line 1100 of file misc_ip.cc.

◆ n_FlintQ

Definition at line 1211 of file misc_ip.cc.

◆ n_FlintZn

Definition at line 1210 of file misc_ip.cc.

◆ optionStruct

const struct soptionStruct optionStruct[]
Initial value:
=
{
{"notBuckets", Sy_bit(OPT_NOT_BUCKETS), ~Sy_bit(OPT_NOT_BUCKETS) },
{"notSugar", Sy_bit(OPT_NOT_SUGAR), ~Sy_bit(OPT_NOT_SUGAR) },
{"interrupt", Sy_bit(OPT_INTERRUPT), ~Sy_bit(OPT_INTERRUPT) },
{"sugarCrit", Sy_bit(OPT_SUGARCRIT), ~Sy_bit(OPT_SUGARCRIT) },
{"teach", Sy_bit(OPT_DEBUG), ~Sy_bit(OPT_DEBUG) },
{"notSyzMinim", Sy_bit(OPT_NO_SYZ_MINIM), ~Sy_bit(OPT_NO_SYZ_MINIM) },
{"returnSB", Sy_bit(OPT_RETURN_SB), ~Sy_bit(OPT_RETURN_SB) },
{"fastHC", Sy_bit(OPT_FASTHC), ~Sy_bit(OPT_FASTHC) },
{"staircaseBound",Sy_bit(OPT_STAIRCASEBOUND),~Sy_bit(OPT_STAIRCASEBOUND) },
{"multBound", Sy_bit(OPT_MULTBOUND), ~Sy_bit(OPT_MULTBOUND) },
{"degBound", Sy_bit(OPT_DEGBOUND), ~Sy_bit(OPT_DEGBOUND) },
{"redTailSyz", Sy_bit(OPT_REDTAIL_SYZ), ~Sy_bit(OPT_REDTAIL_SYZ) },
{"redTail", Sy_bit(OPT_REDTAIL), ~Sy_bit(OPT_REDTAIL) },
{"redThrough", Sy_bit(OPT_REDTHROUGH), ~Sy_bit(OPT_REDTHROUGH) },
{"lazy", Sy_bit(OPT_OLDSTD), ~Sy_bit(OPT_OLDSTD) },
{"intStrategy", Sy_bit(OPT_INTSTRATEGY), ~Sy_bit(OPT_INTSTRATEGY) },
{"infRedTail", Sy_bit(OPT_INFREDTAIL), ~Sy_bit(OPT_INFREDTAIL) },
{"notRegularity",Sy_bit(OPT_NOTREGULARITY), ~Sy_bit(OPT_NOTREGULARITY) },
{"weightM", Sy_bit(OPT_WEIGHTM), ~Sy_bit(OPT_WEIGHTM) },
{"ne", 0, 0 }
}
#define OPT_SUGARCRIT
Definition options.h:81
#define OPT_PROT
Definition options.h:76
#define OPT_INFREDTAIL
Definition options.h:95
#define OPT_WEIGHTM
Definition options.h:98
#define OPT_REDTAIL_SYZ
Definition options.h:88
#define OPT_REDTAIL
Definition options.h:92
#define OPT_RETURN_SB
Definition options.h:85
#define OPT_NOT_SUGAR
Definition options.h:79
#define OPT_REDSB
Definition options.h:77
#define OPT_NOTREGULARITY
Definition options.h:97
#define OPT_DEBUG
Definition options.h:82
#define OPT_MULTBOUND
Definition options.h:90
#define OPT_STAIRCASEBOUND
Definition options.h:89
#define OPT_INTERRUPT
Definition options.h:80
#define OPT_DEGBOUND
Definition options.h:91
#define OPT_NOT_BUCKETS
Definition options.h:78
#define OPT_FASTHC
Definition options.h:86
#define OPT_NO_SYZ_MINIM
Definition options.h:84

Definition at line 508 of file misc_ip.cc.

509{
510 {"prot", Sy_bit(OPT_PROT), ~Sy_bit(OPT_PROT) },
511 {"redSB", Sy_bit(OPT_REDSB), ~Sy_bit(OPT_REDSB) },
512 {"notBuckets", Sy_bit(OPT_NOT_BUCKETS), ~Sy_bit(OPT_NOT_BUCKETS) },
513 {"notSugar", Sy_bit(OPT_NOT_SUGAR), ~Sy_bit(OPT_NOT_SUGAR) },
514 {"interrupt", Sy_bit(OPT_INTERRUPT), ~Sy_bit(OPT_INTERRUPT) },
515 {"sugarCrit", Sy_bit(OPT_SUGARCRIT), ~Sy_bit(OPT_SUGARCRIT) },
516 {"teach", Sy_bit(OPT_DEBUG), ~Sy_bit(OPT_DEBUG) },
517 {"notSyzMinim", Sy_bit(OPT_NO_SYZ_MINIM), ~Sy_bit(OPT_NO_SYZ_MINIM) },
518 /* 9 return SB in syz, quotient, intersect, modulo */
519 {"returnSB", Sy_bit(OPT_RETURN_SB), ~Sy_bit(OPT_RETURN_SB) },
520 {"fastHC", Sy_bit(OPT_FASTHC), ~Sy_bit(OPT_FASTHC) },
521 /* 11-19 sort in L/T */
523 {"multBound", Sy_bit(OPT_MULTBOUND), ~Sy_bit(OPT_MULTBOUND) },
524 {"degBound", Sy_bit(OPT_DEGBOUND), ~Sy_bit(OPT_DEGBOUND) },
525 {"redTailSyz", Sy_bit(OPT_REDTAIL_SYZ), ~Sy_bit(OPT_REDTAIL_SYZ) },
526 /* 25 no redTail(p)/redTail(s) */
527 {"redTail", Sy_bit(OPT_REDTAIL), ~Sy_bit(OPT_REDTAIL) },
528 {"redThrough", Sy_bit(OPT_REDTHROUGH), ~Sy_bit(OPT_REDTHROUGH) },
529 {"lazy", Sy_bit(OPT_OLDSTD), ~Sy_bit(OPT_OLDSTD) },
530 {"intStrategy", Sy_bit(OPT_INTSTRATEGY), ~Sy_bit(OPT_INTSTRATEGY) },
531 {"infRedTail", Sy_bit(OPT_INFREDTAIL), ~Sy_bit(OPT_INFREDTAIL) },
532 /* 30: use not regularity for syz */
534 {"weightM", Sy_bit(OPT_WEIGHTM), ~Sy_bit(OPT_WEIGHTM) },
535/*special for "none" and also end marker for showOption:*/
536 {"ne", 0, 0 }
537};

◆ verboseStruct

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) },
{"usage", Sy_bit(V_SHOW_USE), ~Sy_bit(V_SHOW_USE) },
{"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) },
{"cancelunit",Sy_bit(V_CANCELUNIT),~Sy_bit(V_CANCELUNIT)},
{"modpsolve",Sy_bit(V_MODPSOLVSB),~Sy_bit(V_MODPSOLVSB)},
{"geometricSB",Sy_bit(V_UPTORADICAL),~Sy_bit(V_UPTORADICAL)},
{"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)},
{"warn", Sy_bit(V_ALLWARN), ~Sy_bit(V_ALLWARN)},
{"intersectSyz",Sy_bit(V_INTERSECT_SYZ), ~Sy_bit(V_INTERSECT_SYZ)},
{"intersectElim",Sy_bit(V_INTERSECT_ELIM), ~Sy_bit(V_INTERSECT_ELIM)},
{"pure_gb",Sy_bit(V_PURE_GB), ~Sy_bit(V_PURE_GB)},
{"ne", 0, 0 }
}
#define V_QRING
Definition options.h:42
#define V_DEF_RES
Definition options.h:50
#define V_INTERSECT_SYZ
Definition options.h:69
#define V_ALLWARN
Definition options.h:67
#define V_READING
Definition options.h:46
#define V_COEFSTRAT
Definition options.h:61
#define V_ASSIGN_NONE
Definition options.h:70
#define V_CONTENTSB
Definition options.h:56
#define V_DEBUG_LIB
Definition options.h:48
#define V_MODPSOLVSB
Definition options.h:58
#define V_LOAD_PROC
Definition options.h:49
#define V_UPTORADICAL
Definition options.h:59
#define V_FINDMONOM
Definition options.h:60
#define V_CANCELUNIT
Definition options.h:57
#define V_REDEFINE
Definition options.h:45
#define V_INTERSECT_ELIM
Definition options.h:68
#define V_PURE_GB
Definition options.h:71
#define V_NSB
Definition options.h:55
#define V_LENGTH
Definition options.h:64
#define V_IMAP
Definition options.h:53
#define V_PROMPT
Definition options.h:54
#define V_SHOW_USE
Definition options.h:52

Definition at line 539 of file misc_ip.cc.

540{
541 {"assign_none",Sy_bit(V_ASSIGN_NONE),~Sy_bit(V_ASSIGN_NONE)},
542 {"mem", Sy_bit(V_SHOW_MEM), ~Sy_bit(V_SHOW_MEM) },
543 {"yacc", Sy_bit(V_YACC), ~Sy_bit(V_YACC) },
544 {"redefine", Sy_bit(V_REDEFINE), ~Sy_bit(V_REDEFINE) },
545 {"reading", Sy_bit(V_READING), ~Sy_bit(V_READING) },
546 {"loadLib", Sy_bit(V_LOAD_LIB), ~Sy_bit(V_LOAD_LIB) },
547 {"debugLib", Sy_bit(V_DEBUG_LIB), ~Sy_bit(V_DEBUG_LIB) },
548 {"loadProc", Sy_bit(V_LOAD_PROC), ~Sy_bit(V_LOAD_PROC) },
549 {"defRes", Sy_bit(V_DEF_RES), ~Sy_bit(V_DEF_RES) },
550 {"usage", Sy_bit(V_SHOW_USE), ~Sy_bit(V_SHOW_USE) },
551 {"Imap", Sy_bit(V_IMAP), ~Sy_bit(V_IMAP) },
552 {"prompt", Sy_bit(V_PROMPT), ~Sy_bit(V_PROMPT) },
553 {"length", Sy_bit(V_LENGTH), ~Sy_bit(V_LENGTH) },
554 {"notWarnSB",Sy_bit(V_NSB), ~Sy_bit(V_NSB) },
555 {"contentSB",Sy_bit(V_CONTENTSB), ~Sy_bit(V_CONTENTSB) },
556 {"cancelunit",Sy_bit(V_CANCELUNIT),~Sy_bit(V_CANCELUNIT)},
557 {"modpsolve",Sy_bit(V_MODPSOLVSB),~Sy_bit(V_MODPSOLVSB)},
558 {"geometricSB",Sy_bit(V_UPTORADICAL),~Sy_bit(V_UPTORADICAL)},
559 {"findMonomials",Sy_bit(V_FINDMONOM),~Sy_bit(V_FINDMONOM)},
560 {"coefStrat",Sy_bit(V_COEFSTRAT), ~Sy_bit(V_COEFSTRAT)},
561 {"qringNF", Sy_bit(V_QRING), ~Sy_bit(V_QRING)},
562 {"warn", Sy_bit(V_ALLWARN), ~Sy_bit(V_ALLWARN)},
563 {"intersectSyz",Sy_bit(V_INTERSECT_SYZ), ~Sy_bit(V_INTERSECT_SYZ)},
564 {"intersectElim",Sy_bit(V_INTERSECT_ELIM), ~Sy_bit(V_INTERSECT_ELIM)},
565 {"pure_gb",Sy_bit(V_PURE_GB), ~Sy_bit(V_PURE_GB)},
566/*special for "none" and also end marker for showOption:*/
567 {"ne", 0, 0 }
568};