14 #define PLURAL_INTERNAL_DECLARATIONS 1
22 #include <factory/factory.h>
53 int ui=(int)mpz_get_si(n);
54 if ((((ui<<3)>>3)==ui)
55 && (mpz_cmp_si(n,(
long)ui)==0))
69 if ((((
unsigned long)i)==ui) && (((i<<3)>>3)==i))
81 static unsigned add[] = {4, 2, 4, 2, 4, 6, 2, 6};
89 unsigned int failures;
90 int bound_not_reached=1;
96 mpz_div_2exp (t, t, f);
100 multiplicities[index++] =
f;
106 mpz_tdiv_qr_ui (q, r, t, 3);
107 if (mpz_cmp_ui (r, 0) != 0)
115 multiplicities[index++] =
f;
120 mpz_tdiv_qr_ui (q, r, t, 5);
121 if (mpz_cmp_ui (r, 0) != 0)
129 multiplicities[index++] =
f;
135 unsigned long last_f=0;
136 while (mpz_cmp_ui (t, 1) != 0)
138 mpz_tdiv_qr_ui (q, r, t, f);
139 if (mpz_cmp_ui (r, 0) != 0)
142 if (mpz_cmp_ui (t, f) < 0)
146 if (failures > limit)
148 if ((bound!=0) && (f>
bound))
160 multiplicities[
index]++;
165 multiplicities[index-1]++;
175 return bound_not_reached;
183 unsigned long long k,
l,
i;
187 mpz_init_set_si (last_f, 0);
188 mpz_init_set_si (y, 2);
189 mpz_init_set_si (x, 2);
190 mpz_init_set_si (x1, 2);
191 mpz_init_set_ui (P, 1);
195 while (mpz_cmp_ui (n, 1) != 0)
203 mpz_add_ui (x, x, a);
211 if (mpz_cmp_ui (t1, 1) != 0)
219 if (mpz_cmp_ui (t1, 1) != 0)
225 for (i = 0; i <
k; i++)
229 mpz_add_ui (x, x, a);
239 mpz_add_ui (y, y, a);
243 while (mpz_cmp_ui (t1, 1) == 0);
245 mpz_divexact (n, n, t1);
247 if (!mpz_probab_prime_p (t1, 10))
252 mpn_random (&a_limb, (mp_size_t) 1);
261 if (mpz_cmp(t1,last_f)==0)
263 multiplicities[index-1]++;
269 multiplicities[index++] = 1;
275 if (mpz_probab_prime_p (n, 10))
277 if (mpz_cmp(n,last_f)==0)
279 multiplicities[index-1]++;
285 multiplicities[index++] = 1;
303 unsigned int division_limit;
305 if (mpz_sgn (t) == 0)
309 division_limit = mpz_sizeinbase (t, 2);
310 if (division_limit > 1000)
311 division_limit = 1000 * 1000;
313 division_limit = division_limit * division_limit;
317 if (mpz_cmp_ui (t, 1) != 0)
319 if (mpz_probab_prime_p (t, 10))
322 multiplicities[index++] = 1;
337 int* multiplicities = (
int*)
omAlloc0(1000*
sizeof(
int));
347 factor_gmp(nn,primes,multiplicities,index,pBound);
351 primesL->
Init(index);
352 for (i = 0; i <
index; i++)
362 multiplicitiesL->
Init(index);
363 for (i = 0; i <
index; i++)
366 multiplicitiesL->
m[
i].
data = (
void*)(
long)multiplicities[
i];
372 if (positive==-1) mpz_neg(nn,nn);
443 while (*ss!=
'\0') ss++;
453 if((lib!=
NULL)&&(*lib!=
'\0'))
455 Print(
"// proc %s from lib %s\n",s,lib);
476 sprintf(sing_file,
"%s/%s.sing", res_m, s);
489 s = (
char*)
omAlloc((length+20)*
sizeof(char));
490 got = fread(s,
sizeof(
char), length, fd);
494 Werror(
"Error while reading file %s", sing_file);
499 strcat(s,
"\n;return();\n\n");
508 Werror(
"no example for %s", str);
606 if(strcmp(n,
"get")==0)
615 if(strcmp(n,
"set")==0)
637 if(strcmp(n,
"none")==0)
643 for (i=0; (i==0) || (optionStruct[i-1].
setval!=0); i++)
645 if (strcmp(n,optionStruct[i].
name)==0)
655 Warn(
"cannot set option");
668 else if ((strncmp(n,
"no",2)==0)
669 && (strcmp(n+2,optionStruct[i].name)==0))
676 Warn(
"cannot clear option");
680 for (i=0; (i==0) || (verboseStruct[i-1].
setval!=0); i++)
682 if (strcmp(n,verboseStruct[i].
name)==0)
695 else if ((strncmp(n,
"no",2)==0)
696 && (strcmp(n+2,verboseStruct[i].name)==0))
710 Werror(
"unknown option `%s`",n);
719 extern int om_sing_opt_show_mem;
721 else om_sing_opt_show_mem = 0;
737 for (i=0; optionStruct[
i].
setval!=0; i++)
739 if (optionStruct[i].
setval & tmp)
753 for (i=0; verboseStruct[
i].
setval!=0; i++)
755 if (verboseStruct[i].
setval & tmp)
776 #ifndef __GMP_BITS_PER_MP_LIMB
777 #define __GMP_BITS_PER_MP_LIMB GMP_LIMB_BITS
779 #include <flint/flint.h>
786 StringAppend(
"Singular for %s version %s (%d, %d bit) %s #%s",
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",
984 Print(
"(T)::%s, typ %s level %d data %lx\n",
991 Print(
"====== %s ==============\n",
IDID(hh));
1002 Print(
"%s::%s, typ %s level %d data %lx\n",
1025 Print(
"%s typ %d in Top (should be in ring)\n",
IDID(hh),
IDTYP(hh));
1054 #include <sys/types.h>
1055 #include <sys/stat.h>
1061 return si_fstat(fd,buf);
1079 if (File_Profiling!=
NULL) { fclose(File_Profiling); File_Profiling=
NULL; }
1080 m2_end_called =
TRUE;
1081 #ifdef HAVE_SIMPLEIPC
1093 #endif // HAVE_SIMPLEIPC
1141 printf(
"Auf Wiedersehen.\n");
1143 printf(
"\n$Bye.\n");
1155 printf(
"\nhalt %d\n",i);
1169 fprintf(stderr,
"\nSingular error: no more memory\n");
1211 #ifndef __OPTIMIZE__
1274 #ifdef _SC_NPROCESSORS_ONLN
1275 if ((cpu_n=sysconf(_SC_NPROCESSORS_ONLN))>cpus) cpus=cpu_n;
1276 #elif defined(_SC_NPROCESSORS_CONF)
1277 if ((cpu_n=sysconf(_SC_NPROCESSORS_CONF))>cpus) cpus=cpu_n;
int iiInitArithmetic()
initialisation of arithmetic structured data
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 *)
const CanonicalForm CFMap CFMap int &both_non_zero int n
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)
char name(const Variable &v)
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)/
: 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.