 |
My Project
debian-1:4.1.2-p1+ds-2
|
Go to the documentation of this file.
14 #define PLURAL_INTERNAL_DECLARATIONS 1
21 #include "factory/factory.h"
63 #ifdef READLINE_READLINE_H_OK
64 #include <readline/readline.h>
66 #ifndef RL_VERSION_MAJOR
67 #define RL_VERSION_MAJOR 0
72 #include <NTL/version.h>
73 #include <NTL/tools.h>
89 int ui=(int)mpz_get_si(n);
90 if ((((ui<<3)>>3)==ui)
91 && (mpz_cmp_si(n,(
long)ui)==0))
105 if ((((
unsigned long)
i)==ui) && (((i<<3)>>3)==
i))
124 unsigned *addv =
add;
125 unsigned int failures;
126 int bound_not_reached=1;
131 f = mpz_scan1 (t, 0);
132 mpz_div_2exp (t, t,
f);
136 multiplicities[
index++] =
f;
142 mpz_tdiv_qr_ui (q, r, t, 3);
151 multiplicities[
index++] =
f;
156 mpz_tdiv_qr_ui (q, r, t, 5);
165 multiplicities[
index++] =
f;
171 unsigned long last_f=0;
172 while (mpz_cmp_ui (t, 1) != 0)
174 mpz_tdiv_qr_ui (q, r, t,
f);
178 if (mpz_cmp_ui (t,
f) < 0)
182 if (failures > limit)
196 multiplicities[
index]++;
201 multiplicities[
index-1]++;
211 return bound_not_reached;
219 unsigned long long k,
l,
i;
223 mpz_init_set_ui (last_f, 0);
224 mpz_init_set_ui (
y, 2);
225 mpz_init_set_ui (
x, 2);
226 mpz_init_set_ui (x1, 2);
227 mpz_init_set_ui (P, 1);
231 while (mpz_cmp_ui (n, 1) != 0)
239 mpz_add_ui (
x,
x, a);
247 if (mpz_cmp_ui (t1, 1) != 0)
255 if (mpz_cmp_ui (t1, 1) != 0)
261 for (
i = 0;
i <
k;
i++)
265 mpz_add_ui (
x,
x, a);
275 mpz_add_ui (
y,
y, a);
279 while (mpz_cmp_ui (t1, 1) == 0);
281 mpz_divexact (n, n, t1);
283 if (!mpz_probab_prime_p (t1, 10))
288 mpn_random (&a_limb, (mp_size_t) 1);
297 if (mpz_cmp(t1,last_f)==0)
299 multiplicities[
index-1]++;
305 multiplicities[
index++] = 1;
311 if (mpz_probab_prime_p (n, 10))
313 if (mpz_cmp(n,last_f)==0)
315 multiplicities[
index-1]++;
321 multiplicities[
index++] = 1;
339 unsigned int division_limit;
341 if (mpz_sgn (t) == 0)
345 division_limit = mpz_sizeinbase (t, 2);
346 if (division_limit > 1000)
347 division_limit = 1000 * 1000;
349 division_limit = division_limit * division_limit;
353 if (mpz_cmp_ui (t, 1) != 0)
355 if (mpz_probab_prime_p (t, 10))
358 multiplicities[
index++] = 1;
373 int* multiplicities = (
int*)
omAlloc0(1000*
sizeof(
int));
402 multiplicitiesL->
m[
i].
data = (
void*)(
long)multiplicities[
i];
408 if (positive==-1) mpz_neg(nn,nn);
450 while (*ss!=
'\0') ss++;
460 if((lib!=
NULL)&&(*lib!=
'\0'))
462 Print(
"// proc %s from lib %s\n",
s,lib);
483 sprintf(sing_file,
"%s/%s.sing", res_m,
s);
497 got = fread(
s,
sizeof(
char),
length,
fd);
501 Werror(
"Error while reading file %s", sing_file);
506 strcat(
s,
"\n;return();\n\n");
515 Werror(
"no example for %s", str);
607 if(strcmp(n,
"get")==0)
616 if(strcmp(n,
"set")==0)
636 if(strcmp(n,
"none")==0)
654 WarnS(
"cannot set option");
665 else if ((strncmp(n,
"no",2)==0)
673 WarnS(
"cannot clear option");
692 else if ((strncmp(n,
"no",2)==0)
707 Werror(
"unknown option `%s`",n);
773 #ifndef __GMP_BITS_PER_MP_LIMB
774 #define __GMP_BITS_PER_MP_LIMB GMP_LIMB_BITS
776 #include <flint/flint.h>
780 #ifndef MAKE_DISTRIBUTION
781 const char *singular_date=__DATE__
" " __TIME__;
787 StringAppend(
"Singular for %s version %s (%d, %d bit) %s #%s",
791 VERSION_DATE, GIT_VERSION);
793 singular_date, GIT_VERSION);
797 #if defined(mpir_version)
798 StringAppend(
"MPIR(%s)~GMP(%s),", mpir_version, gmp_version);
799 #elif defined(gmp_version)
817 #if defined(HAVE_DYN_RL)
831 #if defined(HAVE_READLINE) && !defined(FEREAD)
849 #ifdef HAVE_DYNAMIC_LOADING
881 #ifdef __OPTIMIZE_SIZE__
887 #ifdef HAVE_GENERIC_ADD
892 #ifdef HAVE_GENERIC_MULT
914 #define SI_SHOW_BUILTIN_MODULE(name) StringAppend(" %s", #name);
918 #undef SI_SHOW_BUILTIN_MODULE
921 "CC = %s,FLAGS : %s,\n"
922 "CXX = %s,FLAGS : %s,\n"
923 "DEFS : %s,CPPFLAGS : %s,\n"
924 "LDFLAGS : %s,LIBS : %s "
926 "(ver: " __VERSION__
")"
928 "\n",AC_CONFIGURE_ARGS, CC,CFLAGS
" " PTHREAD_CFLAGS,
929 CXX,CXXFLAGS
" " PTHREAD_CFLAGS, DEFS,CPPFLAGS, LDFLAGS,
930 LIBS
" " PTHREAD_LIBS);
938 #if (OM_TRACK > 2) && defined(OM_TRACK_CUSTOM)
939 void p_SetRingOfLeftv(
leftv l, ring r)
951 poly
p=(poly)
l->data;
959 ideal I=(ideal)
l->data;
971 p_SetRingOfLeftv(&d->arg1, r);
972 if (d->argc>1) p_SetRingOfLeftv(&d->arg2, r);
973 if (d->argc>2) p_SetRingOfLeftv(&d->arg3, r);
977 printf(
"type %d not yet implementd in p_SetRingOfLeftv\n",
l->rtyp);
985 void listall(
int showproc)
988 PrintS(
"====== Top ==============\n");
996 Print(
"::%s, typ %s level %d data %lx",
1009 Print(
"(T)::%s, typ %s level %d data %lx\n",
1015 Print(
"====== %s ==============\n",
IDID(hh));
1026 Print(
"%s::%s, typ %s level %d data %lx\n",
1049 Print(
"%s typ %d in Top (should be in ring)\n",
IDID(hh),
IDTYP(hh));
1083 return si_fstat(
fd,
buf);
1103 #ifdef HAVE_SIMPLEIPC
1110 #if PORTABLE_SEMAPHORES
1119 #endif // HAVE_SIMPLEIPC
1170 printf(
"Auf Wiedersehen.\n");
1172 printf(
"\n$Bye.\n");
1184 printf(
"\nhalt %d\n",
i);
1196 fprintf(stderr,
"\nSingular error: no more memory\n");
1230 p.ch=(int)(
long)a->
Data();
1260 float_len=(int)(
long)pnn->
Data();
1261 float_len2=float_len;
1265 float_len2=(int)(
long)pnn->
Data();
1288 if (
h==
NULL)
goto crossprod_error;
1291 if (
h->Typ()!=
CRING_CMD)
goto crossprod_error;
1310 WerrorS(
"expected `crossprod(coeffs, ...)`");
1321 #ifndef __OPTIMIZE__
1390 #ifdef _SC_NPROCESSORS_ONLN
1391 if ((cpu_n=sysconf(_SC_NPROCESSORS_ONLN))>cpus) cpus=cpu_n;
1392 #elif defined(_SC_NPROCESSORS_CONF)
1393 if ((cpu_n=sysconf(_SC_NPROCESSORS_CONF))>cpus) cpus=cpu_n;
static int si_min(const int a, const int b)
EXTERN_VAR BBA_Proc sca_gr_bba
char * fe_fgets_dummy(const char *, char *, int)
short float_len2
additional char-flags, rInit
void feInitResources(const char *argv0)
only used if HAVE_RINGS is defined
const BOOLEAN p_procs_dynamic
coeffs nrnInitCfByName(char *s, n_coeffType n)
static FORCE_INLINE void number2mpz(number n, mpz_t m)
static char * iiGetLibName(const procinfov pi)
find the library of an proc
void iiCheckPack(package &p)
void StringAppendS(const char *st)
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
BOOLEAN iiEStart(char *example, procinfo *pi)
SI_FOREACH_BUILTIN(SI_GET_BUILTIN_MOD_INIT0) }
int iiInitArithmetic()
initialisation of arithmetic structured data
const CanonicalForm int const CFList const Variable & y
void nRegisterCfByName(cfInitCfByNameProc p, n_coeffType n)
#define SHORT_REAL_LENGTH
VAR sipc_sem_t * semaphore[SIPC_MAX_SEMAPHORES]
VAR BOOLEAN singular_in_batchmode
BOOLEAN naInitChar(coeffs cf, void *infoStruct)
Initialize the coeffs object.
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
#define p_SetRingOfLm(p, 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,...
EXTERN_VAR BBA_Proc sca_mora
int singular_fstat(int fd, struct stat *buf)
volatile BOOLEAN m2_end_called
static BOOLEAN length(leftv result, leftv arg)
#define MAKE_DISTRIBUTION
const struct soptionStruct optionStruct[]
void setListEntry(lists L, int index, mpz_t n)
EXTERN_VAR BBA_Proc gnc_gr_mora
const char * feSetOptValue(feOptIndex opt, char *optarg)
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
void feStringAppendBrowsers(int warn)
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
char *(* fe_fgets_stdin)(const char *pr, char *s, int size)
Class used for (list of) interpreter objects.
VAR FILE * File_Profiling
static int factor_using_division(mpz_t t, unsigned int limit, lists primes, int *multiplicities, int &index, unsigned long bound)
void feStringAppendResources(int warn)
real floating point (GMP) numbers
BOOLEAN flintQ_InitChar(coeffs cf, void *infoStruct)
void factoryseed(int s)
random seed initializer
char * fe_fgets(const char *pr, char *s, int size)
int iiAddCproc(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
static BOOLEAN iiCrossProd(leftv res, leftv args)
n_coeffType nRegister(n_coeffType n, cfInitCharProc p)
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 BOOLEAN iiFloat(leftv res, leftv pnn)
used to represent polys as coeffcients
#define TEST_OPT_INTSTRATEGY
static void factor_using_pollard_rho(mpz_t n, unsigned long a, lists primes, int *multiplicities, int &index)
int status int void * buf
static void factor_gmp(mpz_t t, lists primes, int *multiplicities, int &index, unsigned long bound)
void monitor(void *F, int mode)
STATIC_VAR n_coeffType n_FlintZn
void omSingOutOfMemoryFunc()
void PrintS(const char *s)
void setListEntry_ui(lists L, int index, unsigned long ui)
#define SI_SHOW_BUILTIN_MODULE(name)
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 singular_example(char *str)
BOOLEAN slPrepClose(si_link l)
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.
char * iiGetLibProcBuffer(procinfo *pi, int part)
static BOOLEAN rField_is_Ring(const ring r)
static BOOLEAN ii_FlintZn_init(leftv res, leftv a)
#define SI_RESTORE_OPT(A, B)
only used if HAVE_RINGS is defined
STATIC_VAR n_coeffType n_FlintQ
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
void killhdl(idhdl h, package proot)
BOOLEAN flintZn_InitChar(coeffs cf, void *infoStruct)
short float_len
additional char-flags, rInit
BOOLEAN setOption(leftv res, leftv v)
coeffs flintQInitCfByName(char *s, n_coeffType n)
EXTERN_VAR link_list ssiToBeClosed
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
BOOLEAN ntInitChar(coeffs cf, void *infoStruct)
Initialize the coeffs object.
#define OPT_STAIRCASEBOUND
single prescision (6,6) real numbers
char * fe_fgets_stdin_drl(const char *pr, char *s, int size)
static char * feResource(feResourceConfig config, int warn)
void StringSetS(const char *st)
static CanonicalForm bound(const CFMatrix &M)
void Werror(const char *fmt,...)
BOOLEAN slClose(si_link l)
char * fe_fgets_stdin_emu(const char *pr, char *s, int size)
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.
STATIC_VAR unsigned short primes[]
primes, primes_len: used to step through possible extensions
#define SIPC_MAX_SEMAPHORES
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),...
char name(const Variable &v)
void WerrorS(const char *s)
static BOOLEAN rField_has_simple_inverse(const ring r)
ideal k_gnc_gr_mora(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat, const ring _currRing)
static BOOLEAN ii_FlintQ_init(leftv res, leftv a)
VAR int sem_acquired[SIPC_MAX_SEMAPHORES]
EXTERN_VAR struct fe_option feOptSpec[]
EXTERN_VAR volatile BOOLEAN ssiToBeClosed_inactive
ideal k_gnc_gr_bba(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat, const ring _currRing)
const Variable & v
< [in] a sqrfree bivariate poly
#define omCheckAddr(addr)
INLINE_THIS void Init(int l=0)
#define SI_SAVE_OPT(A, B)
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
STATIC_VAR unsigned add[]
const CanonicalForm int s
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 (...
const char * Tok2Cmdname(int tok)
static void * feOptValue(feOptIndex opt)
EXTERN_VAR BBA_Proc sca_bba
#define TEST_RINGDEP_OPTS
BOOLEAN iiLibCmd(char *newlib, BOOLEAN autoexport, BOOLEAN tellerror, BOOLEAN force)
INST_VAR sleftv sLastPrinted
void fe_reset_input_mode()
static FORCE_INLINE number mpz2number(mpz_t m)
static int index(p_Length length, p_Ord ord)
BOOLEAN n2pInitChar(coeffs cf, void *infoStruct)
EXTERN_VAR BBA_Proc gnc_gr_bba
coeffs flintZnInitCfByName(char *s, n_coeffType n)
#define OPT_NOTREGULARITY
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
const struct soptionStruct verboseStruct[]