 |
My Project
debian-1:4.1.1-p2+ds-4build2
|
Go to the documentation of this file.
14 #define PLURAL_INTERNAL_DECLARATIONS 1
24 #include "factory/factory.h"
67 #ifdef READLINE_READLINE_H_OK
68 #include <readline/readline.h>
70 #ifndef RL_VERSION_MAJOR
71 #define RL_VERSION_MAJOR 0
76 #include <NTL/version.h>
77 #include <NTL/tools.h>
93 int ui=(int)mpz_get_si(n);
94 if ((((ui<<3)>>3)==ui)
95 && (mpz_cmp_si(n,(
long)ui)==0))
109 if ((((
unsigned long)
i)==ui) && (((i<<3)>>3)==
i))
121 static unsigned add[] = {4, 2, 4, 2, 4, 6, 2, 6};
128 unsigned *addv =
add;
129 unsigned int failures;
130 int bound_not_reached=1;
135 f = mpz_scan1 (t, 0);
136 mpz_div_2exp (t, t,
f);
140 multiplicities[
index++] =
f;
146 mpz_tdiv_qr_ui (q, r, t, 3);
155 multiplicities[
index++] =
f;
160 mpz_tdiv_qr_ui (q, r, t, 5);
169 multiplicities[
index++] =
f;
175 unsigned long last_f=0;
176 while (mpz_cmp_ui (t, 1) != 0)
178 mpz_tdiv_qr_ui (q, r, t,
f);
182 if (mpz_cmp_ui (t,
f) < 0)
186 if (failures > limit)
200 multiplicities[
index]++;
205 multiplicities[
index-1]++;
215 return bound_not_reached;
223 unsigned long long k,
l,
i;
227 mpz_init_set_ui (last_f, 0);
228 mpz_init_set_ui (
y, 2);
229 mpz_init_set_ui (
x, 2);
230 mpz_init_set_ui (x1, 2);
231 mpz_init_set_ui (P, 1);
235 while (mpz_cmp_ui (n, 1) != 0)
243 mpz_add_ui (
x,
x, a);
251 if (mpz_cmp_ui (t1, 1) != 0)
259 if (mpz_cmp_ui (t1, 1) != 0)
265 for (
i = 0;
i <
k;
i++)
269 mpz_add_ui (
x,
x, a);
279 mpz_add_ui (
y,
y, a);
283 while (mpz_cmp_ui (t1, 1) == 0);
285 mpz_divexact (n, n, t1);
287 if (!mpz_probab_prime_p (t1, 10))
292 mpn_random (&a_limb, (mp_size_t) 1);
301 if (mpz_cmp(t1,last_f)==0)
303 multiplicities[
index-1]++;
309 multiplicities[
index++] = 1;
315 if (mpz_probab_prime_p (n, 10))
317 if (mpz_cmp(n,last_f)==0)
319 multiplicities[
index-1]++;
325 multiplicities[
index++] = 1;
343 unsigned int division_limit;
345 if (mpz_sgn (t) == 0)
349 division_limit = mpz_sizeinbase (t, 2);
350 if (division_limit > 1000)
351 division_limit = 1000 * 1000;
353 division_limit = division_limit * division_limit;
357 if (mpz_cmp_ui (t, 1) != 0)
359 if (mpz_probab_prime_p (t, 10))
362 multiplicities[
index++] = 1;
377 int* multiplicities = (
int*)
omAlloc0(1000*
sizeof(
int));
406 multiplicitiesL->
m[
i].
data = (
void*)(
long)multiplicities[
i];
412 if (positive==-1) mpz_neg(nn,nn);
454 while (*ss!=
'\0') ss++;
464 if((lib!=
NULL)&&(*lib!=
'\0'))
466 Print(
"// proc %s from lib %s\n",
s,lib);
487 sprintf(sing_file,
"%s/%s.sing", res_m,
s);
501 got = fread(
s,
sizeof(
char),
length,
fd);
505 Werror(
"Error while reading file %s", sing_file);
510 strcat(
s,
"\n;return();\n\n");
519 Werror(
"no example for %s", str);
611 if(strcmp(n,
"get")==0)
620 if(strcmp(n,
"set")==0)
640 if(strcmp(n,
"none")==0)
658 WarnS(
"cannot set option");
669 else if ((strncmp(n,
"no",2)==0)
677 WarnS(
"cannot clear option");
696 else if ((strncmp(n,
"no",2)==0)
711 Werror(
"unknown option `%s`",n);
720 extern int om_sing_opt_show_mem;
722 else om_sing_opt_show_mem = 0;
777 #ifndef __GMP_BITS_PER_MP_LIMB
778 #define __GMP_BITS_PER_MP_LIMB GMP_LIMB_BITS
780 #include <flint/flint.h>
784 #ifndef MAKE_DISTRIBUTION
791 StringAppend(
"Singular for %s version %s (%d, %d bit) %s #%s",
794 #ifdef MAKE_DISTRIBUTION
795 VERSION_DATE, GIT_VERSION);
801 #if defined(mpir_version)
802 StringAppend(
"MPIR(%s)~GMP(%s),", mpir_version, gmp_version);
803 #elif defined(gmp_version)
809 #include <NTL/version.h>
822 #if defined(HAVE_DYN_RL)
836 #if defined(HAVE_READLINE) && !defined(FEREAD)
854 #ifdef HAVE_DYNAMIC_LOADING
886 #ifdef __OPTIMIZE_SIZE__
892 #ifdef HAVE_GENERIC_ADD
897 #ifdef HAVE_GENERIC_MULT
919 #define SI_SHOW_BUILTIN_MODULE(name) StringAppend(" %s", #name);
923 #undef SI_SHOW_BUILTIN_MODULE
926 "CC = %s,FLAGS : %s,\n"
927 "CXX = %s,FLAGS : %s,\n"
928 "DEFS : %s,CPPFLAGS : %s,\n"
929 "LDFLAGS : %s,LIBS : %s "
931 "(ver: " __VERSION__
")"
933 "\n",AC_CONFIGURE_ARGS, CC,CFLAGS, CXX,CXXFLAGS, DEFS,CPPFLAGS, LDFLAGS,LIBS);
941 #if (OM_TRACK > 2) && defined(OM_TRACK_CUSTOM)
942 void p_SetRingOfLeftv(
leftv l, ring r)
954 poly
p=(poly)
l->data;
962 ideal I=(ideal)
l->data;
974 p_SetRingOfLeftv(&d->arg1, r);
975 if (d->argc>1) p_SetRingOfLeftv(&d->arg2, r);
976 if (d->argc>2) p_SetRingOfLeftv(&d->arg3, r);
980 printf(
"type %d not yet implementd in p_SetRingOfLeftv\n",
l->rtyp);
988 void listall(
int showproc)
991 PrintS(
"====== Top ==============\n");
999 Print(
"::%s, typ %s level %d data %lx",
1012 Print(
"(T)::%s, typ %s level %d data %lx\n",
1018 Print(
"====== %s ==============\n",
IDID(hh));
1029 Print(
"%s::%s, typ %s level %d data %lx\n",
1052 Print(
"%s typ %d in Top (should be in ring)\n",
IDID(hh),
IDTYP(hh));
1086 return si_fstat(
fd,
buf);
1106 #ifdef HAVE_SIMPLEIPC
1113 #if PORTABLE_SEMAPHORES
1122 #endif // HAVE_SIMPLEIPC
1173 printf(
"Auf Wiedersehen.\n");
1175 printf(
"\n$Bye.\n");
1187 printf(
"\nhalt %d\n",
i);
1199 fprintf(stderr,
"\nSingular error: no more memory\n");
1232 WerrorS(
"`int`i,`string` expected");
1238 p.ch=(int)(
long)a->
Data();
1254 float_len=(int)(
long)pnn->
Data();
1255 float_len2=float_len;
1259 float_len2=(int)(
long)pnn->
Data();
1282 if (
h==
NULL)
goto crossprod_error;
1285 if (
h->Typ()!=
CRING_CMD)
goto crossprod_error;
1304 WerrorS(
"expected `crossprod(coeffs, ...)`");
1322 #ifndef __OPTIMIZE__
1391 #ifdef _SC_NPROCESSORS_ONLN
1392 if ((cpu_n=sysconf(_SC_NPROCESSORS_ONLN))>cpus) cpus=cpu_n;
1393 #elif defined(_SC_NPROCESSORS_CONF)
1394 if ((cpu_n=sysconf(_SC_NPROCESSORS_CONF))>cpus) cpus=cpu_n;
static int si_min(const int a, const int b)
char * fe_fgets_dummy(const char *, char *, int)
short float_len2
additional char-flags, rInit
void feInitResources(const char *argv0)
const BOOLEAN p_procs_dynamic
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)
volatile BOOLEAN ssiToBeClosed_inactive
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
BOOLEAN iiEStart(char *example, procinfo *pi)
sipc_sem_t * semaphore[SIPC_MAX_SEMAPHORES]
SI_FOREACH_BUILTIN(SI_GET_BUILTIN_MOD_INIT0) }
int iiInitArithmetic()
initialisation of arithmetic structured data
const CanonicalForm int const CFList const Variable & y
#define SHORT_REAL_LENGTH
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,...
int singular_fstat(int fd, struct stat *buf)
volatile BOOLEAN m2_end_called
static unsigned short primes[]
primes, primes_len: used to step through possible extensions
static BOOLEAN length(leftv result, leftv arg)
const struct soptionStruct optionStruct[]
void setListEntry(lists L, int index, mpz_t n)
const char * feSetOptValue(feOptIndex opt, char *optarg)
@ n_nTupel
n-tupel of cf: ZZ/p1,...
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
@ n_Q
rational (GMP) numbers
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.
static int factor_using_division(mpz_t t, unsigned int limit, lists primes, int *multiplicities, int &index, unsigned long bound)
void feStringAppendResources(int warn)
@ n_long_R
real floating point (GMP) numbers
BOOLEAN flintQ_InitChar(coeffs cf, void *infoStruct)
void factoryseed(int s)
random seed initializer
BOOLEAN singular_in_batchmode
char * fe_fgets(const char *pr, char *s, int size)
static const int SW_USE_EZGCD
set to 1 to use EZGCD over Z
int iiAddCproc(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
static BOOLEAN iiCrossProd(leftv res, leftv args)
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
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 const int SW_USE_NTL_SORT
set to 1 to sort factors in a factorization
static n_coeffType n_FlintZn
static BOOLEAN iiFloat(leftv res, leftv pnn)
@ n_polyExt
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)
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)
void omPrintStats(FILE *fd)
static BOOLEAN ii_FlintZn_init(leftv res, leftv a)
#define SI_RESTORE_OPT(A, B)
@ n_Z
only used if HAVE_RINGS is defined
const char * singular_date
static const int SW_USE_CHINREM_GCD
set to 1 to use modular gcd over Z
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)
@ n_transExt
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
@ n_R
single prescision (6,6) real numbers
struct fe_option feOptSpec[]
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 const int SW_USE_EZGCD_P
set to 1 to use EZGCD over F_q
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.
#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)
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)
const CanonicalForm int s
const char * Tok2Cmdname(int tok)
static void * feOptValue(feOptIndex opt)
static const int SW_USE_QGCD
set to 1 to use Encarnacion GCD over Q(a)
#define TEST_RINGDEP_OPTS
BOOLEAN iiLibCmd(char *newlib, BOOLEAN autoexport, BOOLEAN tellerror, BOOLEAN force)
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)
int sem_acquired[SIPC_MAX_SEMAPHORES]
#define OPT_NOTREGULARITY
@ n_algExt
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
const struct soptionStruct verboseStruct[]