14 #define PLURAL_INTERNAL_DECLARATIONS 1 22 #include <factory/factory.h> 54 int ui=(int)mpz_get_si(n);
55 if ((((ui<<3)>>3)==ui)
56 && (mpz_cmp_si(n,(
long)ui)==0))
70 if ((((
unsigned long)i)==ui) && (((i<<3)>>3)==i))
82 static unsigned add[] = {4, 2, 4, 2, 4, 6, 2, 6};
90 unsigned int failures;
91 int bound_not_reached=1;
97 mpz_div_2exp (t, t, f);
101 multiplicities[index++] =
f;
107 mpz_tdiv_qr_ui (q, r, t, 3);
108 if (mpz_cmp_ui (r, 0) != 0)
116 multiplicities[index++] =
f;
121 mpz_tdiv_qr_ui (q, r, t, 5);
122 if (mpz_cmp_ui (r, 0) != 0)
130 multiplicities[index++] =
f;
136 unsigned long last_f=0;
137 while (mpz_cmp_ui (t, 1) != 0)
139 mpz_tdiv_qr_ui (q, r, t, f);
140 if (mpz_cmp_ui (r, 0) != 0)
143 if (mpz_cmp_ui (t, f) < 0)
147 if (failures > limit)
149 if ((bound!=0) && (f>
bound))
161 multiplicities[
index]++;
166 multiplicities[index-1]++;
176 return bound_not_reached;
184 unsigned long long k,
l,
i;
188 mpz_init_set_si (last_f, 0);
189 mpz_init_set_si (y, 2);
190 mpz_init_set_si (x, 2);
191 mpz_init_set_si (x1, 2);
192 mpz_init_set_ui (P, 1);
196 while (mpz_cmp_ui (n, 1) != 0)
204 mpz_add_ui (x, x, a);
212 if (mpz_cmp_ui (t1, 1) != 0)
220 if (mpz_cmp_ui (t1, 1) != 0)
226 for (i = 0; i <
k; i++)
230 mpz_add_ui (x, x, a);
240 mpz_add_ui (y, y, a);
244 while (mpz_cmp_ui (t1, 1) == 0);
246 mpz_divexact (n, n, t1);
248 if (!mpz_probab_prime_p (t1, 10))
253 mpn_random (&a_limb, (mp_size_t) 1);
262 if (mpz_cmp(t1,last_f)==0)
264 multiplicities[index-1]++;
270 multiplicities[index++] = 1;
276 if (mpz_probab_prime_p (n, 10))
278 if (mpz_cmp(n,last_f)==0)
280 multiplicities[index-1]++;
286 multiplicities[index++] = 1;
304 unsigned int division_limit;
306 if (mpz_sgn (t) == 0)
310 division_limit = mpz_sizeinbase (t, 2);
311 if (division_limit > 1000)
312 division_limit = 1000 * 1000;
314 division_limit = division_limit * division_limit;
318 if (mpz_cmp_ui (t, 1) != 0)
320 if (mpz_probab_prime_p (t, 10))
323 multiplicities[index++] = 1;
338 int* multiplicities = (
int*)
omAlloc0(1000*
sizeof(
int));
348 factor_gmp(nn,primes,multiplicities,index,pBound);
352 primesL->
Init(index);
353 for (i = 0; i <
index; i++)
363 multiplicitiesL->
Init(index);
364 for (i = 0; i <
index; i++)
367 multiplicitiesL->
m[
i].
data = (
void*)(
long)multiplicities[
i];
373 if (positive==-1) mpz_neg(nn,nn);
444 while (*ss!=
'\0') ss++;
454 if((lib!=
NULL)&&(*lib!=
'\0'))
456 Print(
"// proc %s from lib %s\n",s,lib);
477 sprintf(sing_file,
"%s/%s.sing", res_m, s);
490 s = (
char*)
omAlloc((length+20)*
sizeof(char));
491 got = fread(s,
sizeof(
char), length, fd);
495 Werror(
"Error while reading file %s", sing_file);
500 strcat(s,
"\n;return();\n\n");
509 Werror(
"no example for %s", str);
607 if(strcmp(n,
"get")==0)
616 if(strcmp(n,
"set")==0)
638 if(strcmp(n,
"none")==0)
644 for (i=0; (i==0) || (optionStruct[i-1].
setval!=0); i++)
646 if (strcmp(n,optionStruct[i].
name)==0)
656 Warn(
"cannot set option");
669 else if ((strncmp(n,
"no",2)==0)
670 && (strcmp(n+2,optionStruct[i].name)==0))
677 Warn(
"cannot clear option");
681 for (i=0; (i==0) || (verboseStruct[i-1].
setval!=0); i++)
683 if (strcmp(n,verboseStruct[i].
name)==0)
696 else if ((strncmp(n,
"no",2)==0)
697 && (strcmp(n+2,verboseStruct[i].name)==0))
711 Werror(
"unknown option `%s`",n);
720 extern int om_sing_opt_show_mem;
722 else om_sing_opt_show_mem = 0;
738 for (i=0; optionStruct[
i].
setval!=0; i++)
740 if (optionStruct[i].
setval & tmp)
754 for (i=0; verboseStruct[
i].
setval!=0; i++)
756 if (verboseStruct[i].
setval & tmp)
777 #ifndef __GMP_BITS_PER_MP_LIMB 778 #define __GMP_BITS_PER_MP_LIMB GMP_LIMB_BITS 780 #include <flint/flint.h> 787 StringAppend(
"Singular for %s version %s (%d, %d bit) %s #%s",
792 #if defined(mpir_version) 793 StringAppend(
"MPIR(%s)~GMP(%s),", mpir_version, gmp_version);
794 #elif defined(gmp_version) 800 #include <NTL/version.h> 808 #if defined(HAVE_DYN_RL) 822 #if defined(HAVE_READLINE) && !defined(FEREAD) 840 #ifdef HAVE_DYNAMIC_LOADING 874 #ifdef __OPTIMIZE_SIZE__ 891 #define SI_SHOW_BUILTIN_MODULE(name) StringAppend(" %s", #name); 895 #undef SI_SHOW_BUILTIN_MODULE 898 "CC = %s,FLAGS : %s,\n" 899 "CXX = %s,FLAGS : %s,\n" 900 "DEFS : %s,CPPFLAGS : %s,\n" 901 "LDFLAGS : %s,LIBS : %s " 903 "(ver: " __VERSION__
")" 905 "\n",AC_CONFIGURE_ARGS, CC,CFLAGS, CXX,CXXFLAGS, DEFS,CPPFLAGS, LDFLAGS,LIBS);
913 #if (OM_TRACK > 2) && defined(OM_TRACK_CUSTOM) 914 void p_SetRingOfLeftv(
leftv l, ring
r)
934 ideal I=(ideal)l->
data;
946 p_SetRingOfLeftv(&d->arg1, r);
947 if (d->argc>1) p_SetRingOfLeftv(&d->arg2, r);
948 if (d->argc>2) p_SetRingOfLeftv(&d->arg3, r);
952 printf(
"type %d not yet implementd in p_SetRingOfLeftv\n",l->
rtyp);
960 void listall(
int showproc)
963 PrintS(
"====== Top ==============\n");
971 Print(
"::%s, typ %s level %d data %lx",
985 Print(
"(T)::%s, typ %s level %d data %lx\n",
992 Print(
"====== %s ==============\n",
IDID(hh));
1003 Print(
"%s::%s, typ %s level %d data %lx\n",
1026 Print(
"%s typ %d in Top (should be in ring)\n",
IDID(hh),
IDTYP(hh));
1055 #include <sys/types.h> 1056 #include <sys/stat.h> 1062 return si_fstat(fd,buf);
1080 if (File_Profiling!=
NULL) { fclose(File_Profiling); File_Profiling=
NULL; }
1081 m2_end_called =
TRUE;
1082 #ifdef HAVE_SIMPLEIPC 1094 #endif // HAVE_SIMPLEIPC 1142 printf(
"Auf Wiedersehen.\n");
1144 printf(
"\n$Bye.\n");
1156 printf(
"\nhalt %d\n",i);
1170 fprintf(stderr,
"\nSingular error: no more memory\n");
1212 #ifndef __OPTIMIZE__ 1275 #ifdef _SC_NPROCESSORS_ONLN 1276 if ((cpu_n=sysconf(_SC_NPROCESSORS_ONLN))>cpus) cpus=cpu_n;
1277 #elif defined(_SC_NPROCESSORS_CONF) 1278 if ((cpu_n=sysconf(_SC_NPROCESSORS_CONF))>cpus) cpus=cpu_n;
int iiInitArithmetic()
initialisation of arithmetic structured data
BOOLEAN flintQ_InitChar(coeffs cf, void *infoStruct)
static void factor_gmp(mpz_t t, lists primes, int *multiplicities, int &index, unsigned long bound)
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.
void omSingOutOfMemoryFunc()
const CanonicalForm int s
This file provides miscellaneous functionality.
char *(* fe_fgets_stdin)(const char *pr, char *s, int size)
const CanonicalForm int const CFList const Variable & y
BOOLEAN n_AEInitChar(coeffs r, void *)
void factoryseed(int s)
random seed initializer
Class used for (list of) interpreter objects.
ideal k_gnc_gr_bba(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat, const ring _currRing)
void singular_example(char *str)
static FORCE_INLINE void number2mpz(number n, mpz_t m)
static CanonicalForm bound(const CFMatrix &M)
void feStringAppendResources(int warn)
const BOOLEAN p_procs_dynamic
ideal k_sca_bba(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat, const ring _currRing)
Modified modern Sinuglar Buchberger's algorithm.
ideal k_sca_gr_bba(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat, const ring _currRing)
Modified Plural's Buchberger's algorithmus.
static void * feOptValue(feOptIndex opt)
BOOLEAN naInitChar(coeffs cf, void *infoStruct)
Initialize the coeffs object.
ideal k_sca_mora(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat, const ring _currRing)
Modified modern Sinuglar Mora's algorithm.
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
volatile BOOLEAN m2_end_called
static void factor_using_pollard_rho(mpz_t n, unsigned long a, lists primes, int *multiplicities, int &index)
void setListEntry(lists L, int index, mpz_t n)
static char * feResource(feResourceConfig config, int warn)
char * fe_fgets(const char *pr, char *s, int size)
static const int SW_USE_EZGCD_P
set to 1 to use EZGCD over F_q
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
int singular_fstat(int fd, struct stat *buf)
BOOLEAN n_QAEInitChar(coeffs r, void *)
char * fe_fgets_dummy(const char *, char *, int)
static const int SW_USE_NTL_SORT
set to 1 to sort factors in a factorization
static unsigned short primes[]
primes, primes_len: used to step through possible extensions
SI_FOREACH_BUILTIN(SI_GET_BUILTIN_MOD_INIT0)}
const char * feSetOptValue(feOptIndex opt, char *optarg)
void feInitResources(const char *argv0)
void WerrorS(const char *s)
void omPrintStats(FILE *fd)
volatile BOOLEAN ssiToBeClosed_inactive
static FORCE_INLINE number mpz2number(mpz_t m)
BOOLEAN iiLibCmd(char *newlib, BOOLEAN autoexport, BOOLEAN tellerror, BOOLEAN force)
void monitor(void *F, int mode)
static BOOLEAN rField_has_simple_inverse(const ring r)
void feStringAppendBrowsers(int warn)
void setListEntry_ui(lists L, int index, unsigned long ui)
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
sem_t * semaphore[SIPC_MAX_SEMAPHORES]
#define SI_RESTORE_OPT(A, B)
BOOLEAN singular_in_batchmode
Coefficient rings, fields and other domains suitable for Singular polynomials.
#define TEST_OPT_INTSTRATEGY
n_coeffType nRegister(n_coeffType n, cfInitCharProc p)
#define p_SetRingOfLm(p, r)
struct soptionStruct verboseStruct[]
char * fe_fgets_stdin_emu(const char *pr, char *s, int size)
void StringSetS(const char *st)
int status int void * buf
struct soptionStruct optionStruct[]
BOOLEAN slPrepClose(si_link l)
void StringAppendS(const char *st)
struct fe_option feOptSpec[]
void fe_reset_input_mode()
#define OPT_STAIRCASEBOUND
only used if HAVE_RINGS is defined: ?
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
void PrintS(const char *s)
ideal k_gnc_gr_mora(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat, const ring _currRing)
static const int SW_USE_CHINREM_GCD
set to 1 to use modular gcd over Z
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
BOOLEAN iiEStart(char *example, procinfo *pi)
static int index(p_Length length, p_Ord ord)
INLINE_THIS void Init(int l=0)
const Variable & v
< [in] a sqrfree bivariate poly
BOOLEAN n_pAEInitChar(coeffs r, void *p)
static BOOLEAN rField_is_Ring(const ring r)
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...
const char * Tok2Cmdname(int tok)
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic ...
void killhdl(idhdl h, package proot)
const char * singular_date
static const int SW_USE_QGCD
set to 1 to use Encarnacion GCD over Q(a)
static const int SW_USE_EZGCD
set to 1 to use EZGCD over Z
#define SI_SAVE_OPT(A, B)
#define SIPC_MAX_SEMAPHORES
void Clean(ring r=currRing)
char * iiGetLibName(procinfov pi)
#define SI_SHOW_BUILTIN_MODULE(name)
const char factoryVersion[]
extern const char factoryVersion[];
#define TEST_RINGDEP_OPTS
#define omCheckAddr(addr)
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff 'n' is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long representing n in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or (Im(n) == 0 and Re(n) >= 0) in K(a)/<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
void iiCheckPack(package &p)
int iiAddCproc(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
BOOLEAN slClose(si_link l)
#define OPT_NOTREGULARITY
char * fe_fgets_stdin_drl(const char *pr, char *s, int size)
int sem_acquired[SIPC_MAX_SEMAPHORES]
static int factor_using_division(mpz_t t, unsigned int limit, lists primes, int *multiplicities, int &index, unsigned long bound)
char * iiGetLibProcBuffer(procinfo *pi, int part)
static BOOLEAN ii_pAE_init(leftv res, leftv a)
void Werror(const char *fmt,...)
void(* factoryError)(const char *s)
BOOLEAN setOption(leftv res, leftv v)
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
BOOLEAN ntInitChar(coeffs cf, void *infoStruct)
Initialize the coeffs object.