14 #define PLURAL_INTERNAL_DECLARATIONS 1 21 #include <factory/factory.h> 55 int ui=(int)mpz_get_si(n);
56 if ((((ui<<3)>>3)==ui)
57 && (mpz_cmp_si(n,(
long)ui)==0))
71 if ((((
unsigned long)i)==ui) && (((i<<3)>>3)==i))
83 static unsigned add[] = {4, 2, 4, 2, 4, 6, 2, 6};
91 unsigned int failures;
92 int bound_not_reached=1;
98 mpz_div_2exp (t, t, f);
102 multiplicities[index++] =
f;
108 mpz_tdiv_qr_ui (q, r, t, 3);
109 if (mpz_cmp_ui (r, 0) != 0)
117 multiplicities[index++] =
f;
122 mpz_tdiv_qr_ui (q, r, t, 5);
123 if (mpz_cmp_ui (r, 0) != 0)
131 multiplicities[index++] =
f;
137 unsigned long last_f=0;
138 while (mpz_cmp_ui (t, 1) != 0)
140 mpz_tdiv_qr_ui (q, r, t, f);
141 if (mpz_cmp_ui (r, 0) != 0)
144 if (mpz_cmp_ui (t, f) < 0)
148 if (failures > limit)
150 if ((bound!=0) && (f>
bound))
162 multiplicities[
index]++;
167 multiplicities[index-1]++;
177 return bound_not_reached;
185 unsigned long long k,
l,
i;
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);
197 while (mpz_cmp_ui (n, 1) != 0)
205 mpz_add_ui (x, x, a);
213 if (mpz_cmp_ui (t1, 1) != 0)
221 if (mpz_cmp_ui (t1, 1) != 0)
227 for (i = 0; i <
k; i++)
231 mpz_add_ui (x, x, a);
241 mpz_add_ui (y, y, a);
245 while (mpz_cmp_ui (t1, 1) == 0);
247 mpz_divexact (n, n, t1);
249 if (!mpz_probab_prime_p (t1, 10))
254 mpn_random (&a_limb, (mp_size_t) 1);
263 if (mpz_cmp(t1,last_f)==0)
265 multiplicities[index-1]++;
271 multiplicities[index++] = 1;
277 if (mpz_probab_prime_p (n, 10))
279 if (mpz_cmp(n,last_f)==0)
281 multiplicities[index-1]++;
287 multiplicities[index++] = 1;
305 unsigned int division_limit;
307 if (mpz_sgn (t) == 0)
311 division_limit = mpz_sizeinbase (t, 2);
312 if (division_limit > 1000)
313 division_limit = 1000 * 1000;
315 division_limit = division_limit * division_limit;
319 if (mpz_cmp_ui (t, 1) != 0)
321 if (mpz_probab_prime_p (t, 10))
324 multiplicities[index++] = 1;
339 int* multiplicities = (
int*)
omAlloc0(1000*
sizeof(
int));
349 factor_gmp(nn,primes,multiplicities,index,pBound);
353 primesL->
Init(index);
354 for (i = 0; i <
index; i++)
364 multiplicitiesL->
Init(index);
365 for (i = 0; i <
index; i++)
368 multiplicitiesL->
m[
i].
data = (
void*)(
long)multiplicities[
i];
374 if (positive==-1) mpz_neg(nn,nn);
445 while (*ss!=
'\0') ss++;
455 if((lib!=
NULL)&&(*lib!=
'\0'))
457 Print(
"// proc %s from lib %s\n",s,lib);
478 sprintf(sing_file,
"%s/%s.sing", res_m, s);
491 s = (
char*)
omAlloc((length+20)*
sizeof(char));
492 got = fread(s,
sizeof(
char), length, fd);
496 Werror(
"Error while reading file %s", sing_file);
501 strcat(s,
"\n;return();\n\n");
510 Werror(
"no example for %s", str);
601 if(strcmp(n,
"get")==0)
610 if(strcmp(n,
"set")==0)
630 if(strcmp(n,
"none")==0)
636 for (i=0; (i==0) || (optionStruct[i-1].
setval!=0); i++)
638 if (strcmp(n,optionStruct[i].
name)==0)
648 Warn(
"cannot set option");
659 else if ((strncmp(n,
"no",2)==0)
660 && (strcmp(n+2,optionStruct[i].name)==0))
667 Warn(
"cannot clear option");
671 for (i=0; (i==0) || (verboseStruct[i-1].
setval!=0); i++)
673 if (strcmp(n,verboseStruct[i].
name)==0)
686 else if ((strncmp(n,
"no",2)==0)
687 && (strcmp(n+2,verboseStruct[i].name)==0))
701 Werror(
"unknown option `%s`",n);
710 extern int om_sing_opt_show_mem;
712 else om_sing_opt_show_mem = 0;
728 for (i=0; optionStruct[
i].
setval!=0; i++)
730 if (optionStruct[i].
setval & tmp)
744 for (i=0; verboseStruct[
i].
setval!=0; i++)
746 if (verboseStruct[i].
setval & tmp)
767 #ifndef __GMP_BITS_PER_MP_LIMB 768 #define __GMP_BITS_PER_MP_LIMB GMP_LIMB_BITS 770 #include <flint/flint.h> 774 #ifndef MAKE_DISTRIBUTION 775 const char *singular_date=__DATE__
" " __TIME__;
781 StringAppend(
"Singular for %s version %s (%d, %d bit) %s #%s",
785 VERSION_DATE, GIT_VERSION);
787 singular_date, GIT_VERSION);
791 #if defined(mpir_version) 792 StringAppend(
"MPIR(%s)~GMP(%s),", mpir_version, gmp_version);
793 #elif defined(gmp_version) 799 #include <NTL/version.h> 807 #if defined(HAVE_DYN_RL) 821 #if defined(HAVE_READLINE) && !defined(FEREAD) 839 #ifdef HAVE_DYNAMIC_LOADING 873 #ifdef __OPTIMIZE_SIZE__ 890 #define SI_SHOW_BUILTIN_MODULE(name) StringAppend(" %s", #name); 894 #undef SI_SHOW_BUILTIN_MODULE 897 "CC = %s,FLAGS : %s,\n" 898 "CXX = %s,FLAGS : %s,\n" 899 "DEFS : %s,CPPFLAGS : %s,\n" 900 "LDFLAGS : %s,LIBS : %s " 902 "(ver: " __VERSION__
")" 904 "\n",AC_CONFIGURE_ARGS, CC,CFLAGS, CXX,CXXFLAGS, DEFS,CPPFLAGS, LDFLAGS,LIBS);
912 #if (OM_TRACK > 2) && defined(OM_TRACK_CUSTOM) 913 void p_SetRingOfLeftv(
leftv l, ring
r)
933 ideal I=(ideal)l->
data;
945 p_SetRingOfLeftv(&d->arg1, r);
946 if (d->argc>1) p_SetRingOfLeftv(&d->arg2, r);
947 if (d->argc>2) p_SetRingOfLeftv(&d->arg3, r);
951 printf(
"type %d not yet implementd in p_SetRingOfLeftv\n",l->
rtyp);
959 void listall(
int showproc)
962 PrintS(
"====== Top ==============\n");
970 Print(
"::%s, typ %s level %d data %lx",
983 Print(
"(T)::%s, typ %s level %d data %lx\n",
989 Print(
"====== %s ==============\n",
IDID(hh));
1000 Print(
"%s::%s, typ %s level %d data %lx\n",
1023 Print(
"%s typ %d in Top (should be in ring)\n",
IDID(hh),
IDTYP(hh));
1052 #include <sys/types.h> 1053 #include <sys/stat.h> 1059 return si_fstat(fd,buf);
1077 if (File_Profiling!=
NULL) { fclose(File_Profiling); File_Profiling=
NULL; }
1078 m2_end_called =
TRUE;
1079 #ifdef HAVE_SIMPLEIPC 1086 #if PORTABLE_SEMAPHORES 1095 #endif // HAVE_SIMPLEIPC 1143 printf(
"Auf Wiedersehen.\n");
1145 printf(
"\n$Bye.\n");
1157 printf(
"\nhalt %d\n",i);
1169 fprintf(stderr,
"\nSingular error: no more memory\n");
1202 WerrorS(
"`int`i,`string` expected");
1208 p.
ch=(int)(
long)a->
Data();
1233 #ifndef __OPTIMIZE__ 1302 #ifdef _SC_NPROCESSORS_ONLN 1303 if ((cpu_n=sysconf(_SC_NPROCESSORS_ONLN))>cpus) cpus=cpu_n;
1304 #elif defined(_SC_NPROCESSORS_CONF) 1305 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
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 n_coeffType n_FlintZn
sipc_sem_t * semaphore[SIPC_MAX_SEMAPHORES]
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)
const struct soptionStruct optionStruct[]
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)
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
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)
BOOLEAN n2pInitChar(coeffs cf, void *infoStruct)
#define MAKE_DISTRIBUTION
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)
#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)
char * fe_fgets_stdin_emu(const char *pr, char *s, int size)
void StringSetS(const char *st)
int status int void * buf
BOOLEAN slPrepClose(si_link l)
void StringAppendS(const char *st)
static BOOLEAN ii_FlintZn_init(leftv res, leftv a)
struct fe_option feOptSpec[]
void fe_reset_input_mode()
SI_FOREACH_BUILTIN(SI_GET_BUILTIN_MOD_INIT0) }
#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)
const struct soptionStruct verboseStruct[]
char name(const Variable &v)
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 flintZn_InitChar(coeffs cf, void *infoStruct)
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)
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)
void Werror(const char *fmt,...)
used to represent polys as coeffcients
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.