26 if ((((
long)a<0L) || ((
long)a>(
long)r->mod2mMask))
27 && (r->mod2mMask!= ~0
UL))
29 Print(
"wrong mod 2^n number %ld (m:%ld) at %s,%d\n",(
long)a,(
long)r->mod2mMask,
f,
l);
40 ((((
unsigned long) a) * ((
unsigned long)
b)) & r->mod2mMask);
46 ((((
unsigned long) a) * ((
unsigned long)
b)) & r->mod2mMask);
52 ((((
unsigned long) a) + ((
unsigned long)
b)) & r->mod2mMask);
58 ((((
unsigned long) a) + ((
unsigned long)
b)) & r->mod2mMask);
63 return (
number)((
unsigned long)a < (
unsigned long)
b ?
64 r->mod2mMask+1 - (
unsigned long)
b + (
unsigned long)a:
65 (
unsigned long)a - (
unsigned long)
b);
68#define nr2mNegM(A,r) (number)((r->mod2mMask+1 - (unsigned long)(A)) & r->mod2mMask)
69#define nr2mEqualM(A,B) ((A)==(B))
76 if (
cf->modExponent>32)
88 unsigned long mm=r->mod2mMask;
89 if (((
mm+1)>>
m)==1L)
return TRUE;
97 long ch = r->cfInt(c, r);
107 WerrorS(
"constant in q-ideal is coprime to modulus in ground ring");
108 WerrorS(
"Unable to create qring!");
135 if ((
unsigned long)
k == 0)
return FALSE;
136 if ((
unsigned long)
k > ((r->mod2mMask >> 1) + 1))
return FALSE;
146 if (((
unsigned long)a == 0) || ((
unsigned long)
b == 0))
156 if (((
unsigned long)a == 0) || ((
unsigned long)
b == 0))
169 unsigned long res = 0;
170 if ((
unsigned long)a == 0) a = (
number) 1;
171 if ((
unsigned long)
b == 0)
b = (
number) 1;
172 while ((
unsigned long)a % 2 == 0)
174 a = (
number)((
unsigned long)a / 2);
175 if ((
unsigned long)
b % 2 == 0)
b = (
number)((
unsigned long)
b / 2);
178 while ((
unsigned long)
b % 2 == 0)
192 unsigned long res = 0;
193 if ((
unsigned long)a == 0 && (
unsigned long)
b == 0)
return (
number)1;
194 while ((
unsigned long)a % 2 == 0 && (
unsigned long)
b % 2 == 0)
196 a = (
number)((
unsigned long)a / 2);
274 assume((
unsigned long)a % 2 != 0);
282 assume((
unsigned long)c % 2 != 0);
291 if ((
unsigned long)c % 2 == 0)
293 WerrorS(
"division by zero divisor");
305 unsigned long res = 0;
306 if ((
unsigned long)a == 0 && (
unsigned long)
b == 0)
return (
number)1;
307 while ((
unsigned long)a % 2 == 0 && (
unsigned long)
b % 2 == 0)
309 a = (
number)((
unsigned long)a / 2);
313 if ((
unsigned long)
b % 2 == 0)
331 *(
unsigned long *)
result = 1;
352 unsigned long j = (
unsigned long)1;
353 if (
ii < 0) {
j = r->mod2mMask;
ii = -
ii; }
354 unsigned long k = (
unsigned long)
ii;
355 k =
k & r->mod2mMask;
366 unsigned long nn = (
unsigned long)n;
367 unsigned long l = r->mod2mMask >> 1;
l++;
368 if ((
unsigned long)
nn >
l)
369 return (
long)((
unsigned long)
nn - r->mod2mMask - 1);
371 return (
long)((
unsigned long)
nn);
396 return ((
unsigned long)a % 2 == 1);
402 unsigned long erg = (
unsigned long)
k;
409 return 0 == (
unsigned long)a;
414 return 1 == (
unsigned long)a;
419 return ((r->mod2mMask == (
unsigned long)a) &&(1L!=(
long)a));
429 if ((
unsigned long)a == 0)
return (
number)0;
430 else if ((
unsigned long)
b % 2 == 0)
432 if ((
unsigned long)
b != 0)
434 while (((
unsigned long)
b % 2 == 0) && ((
unsigned long)a % 2 == 0))
436 a = (
number)((
unsigned long)a / 2);
445 else if ((
unsigned long)
b % 2 == 0)
447 WerrorS(
"Division not possible, even by cancelling zero divisors.");
448 WerrorS(
"Result is integer division without remainder.");
449 return (
number) ((
unsigned long) a / (
unsigned long)
b);
464 unsigned long c = r->mod2mMask + 1;
466 return (c % (
unsigned long)
b) == 0;
471 c = (
unsigned long)
b;
474 if ((c % 2) != 0)
return FALSE;
495 unsigned long a = (
unsigned long)
as;
496 unsigned long b = (
unsigned long)
bs;
498 while (a % 2 == 0 &&
b % 2 == 0)
543 assume((
unsigned long)
b != 0);
553 unsigned long rr = 0;
560 if (
g != 1)
rr = (
unsigned long)a %
g;
568 if ((
unsigned long)a == 0)
570 if ((
unsigned long)
b == 0)
572 if ((
unsigned long)
b == 1)
574 unsigned long c = r->mod2mMask + 1;
590 if ((
unsigned long)
b == 0)
592 return (
number)((
unsigned long) a / (
unsigned long)
b);
599 if ((
unsigned long)
b == 0)
601 if ((
unsigned long)
b == 1)
603 unsigned long c = r->mod2mMask + 1;
620 if ((
unsigned long)c == 0)
return c;
628 unsigned long i = ((
unsigned long)from) % (
dst->mod2mMask + 1) ;
634 unsigned long i = ((
unsigned long)from) % (
dst->mod2mMask + 1);
640 unsigned long j = (
unsigned long)1;
643 unsigned long i = (
unsigned long)
ii;
644 i =
i &
dst->mod2mMask;
687 && (src->mod2mMask <
dst->mod2mMask))
692 && (src->mod2mMask >
dst->mod2mMask))
734 for (
int i = 1;
i <
m;
i++) r->mod2mMask = (r->mod2mMask << 1) + 1;
748 WarnS(
"nr2mInitExp unexpectedly called with m = 1 (we continue with Z/2^2");
760 if (((*
s) >=
'0') && ((*
s) <=
'9'))
767 if ((*
i) >= (
MAX_INT_VAL / 10)) (*i) = (*i) & r->mod2mMask;
769 while (((*
s) >=
'0') && ((*
s) <=
'9'));
770 (*i) = (*i) & r->mod2mMask;
811 mpz_pow_ui (r->modNumber, r->modBase, r->modExponent);
814 r->ch = (
int)r->mod2mMask + 1;
853 r->has_simple_Alloc=
TRUE;
Coefficient rings, fields and other domains suitable for Singular polynomials.
static FORCE_INLINE BOOLEAN nCoeff_is_Z(const coeffs r)
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_PtoM(const coeffs r)
@ n_Z2m
only used if HAVE_RINGS is defined
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
static FORCE_INLINE BOOLEAN nCoeff_is_Zn(const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_2toM(const coeffs r)
@ n_rep_gap_rat
(number), see longrat.h
@ n_rep_gap_gmp
(), see rinteger.h, new impl.
@ n_rep_int
(int), see modulop.h
@ n_rep_gmp
(mpz_ptr), see rmodulon,h
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
const CanonicalForm int s
const Variable & v
< [in] a sqrfree bivariate poly
void WerrorS(const char *s)
void nlMPZ(mpz_t m, number &n, const coeffs r)
The main handler for Singular numbers which are suitable for Singular polynomials.
const char *const nDivBy0
#define omFreeBinAddr(addr)
static number nr2mInversM(number c, const coeffs r)
static number nr2mGcd(number a, number b, const coeffs)
static nMapFunc nr2mSetMap(const coeffs src, const coeffs dst)
static unsigned long InvMod(unsigned long a, const coeffs r)
static const char * nr2mEati(const char *s, int *i, const coeffs r)
static void nr2mWrite(number a, const coeffs r)
static void nr2mSetExp(int m, coeffs r)
static void specialXGCD(unsigned long &s, unsigned long a, const coeffs r)
static number nr2mMapProject(number from, const coeffs, const coeffs dst)
static BOOLEAN nr2mIsUnit(number a, const coeffs)
static void nr2mInpAdd(number &a, number b, const coeffs r)
static number nr2mMapQ(number from, const coeffs src, const coeffs dst)
static number nr2mSub(number a, number b, const coeffs r)
static number nr2mLcm(number a, number b, const coeffs)
static BOOLEAN nr2mIsOne(number a, const coeffs)
BOOLEAN nr2mInitChar(coeffs r, void *p)
static number nr2mAnn(number b, const coeffs r)
static number nr2mInit(long i, const coeffs r)
static number nr2mExtGcd(number a, number b, number *s, number *t, const coeffs r)
static number nr2mGetUnit(number k, const coeffs)
static void nr2mInitExp(int m, coeffs r)
static void nr2mPower(number a, int i, number *result, const coeffs r)
static number nr2mInvers(number c, const coeffs r)
static number nr2mMultM(number a, number b, const coeffs r)
static number nr2mMapGMP(number from, const coeffs, const coeffs dst)
number nr2mMapZp(number from, const coeffs, const coeffs dst)
static int nr2mDivComp(number as, number bs, const coeffs)
static number nr2mMult(number a, number b, const coeffs r)
static long nr2mInt(number &n, const coeffs r)
static BOOLEAN nr2mDivBy(number a, number b, const coeffs r)
static BOOLEAN nr2mGreaterZero(number k, const coeffs r)
static number nr2mMapMachineInt(number from, const coeffs, const coeffs dst)
static number nr2mNeg(number c, const coeffs r)
EXTERN_VAR omBin gmp_nrz_bin
static BOOLEAN nr2mDBTest(number a, const char *f, const int l, const coeffs r)
static number nr2mMod(number a, number b, const coeffs r)
static BOOLEAN nr2mCoeffIsEqual(const coeffs r, n_coeffType n, void *p)
static number nr2mAdd(number a, number b, const coeffs r)
static void nr2mInpMult(number &a, number b, const coeffs r)
static char * nr2mCoeffName(const coeffs cf)
static number nr2mMapZ(number from, const coeffs src, const coeffs dst)
static BOOLEAN nr2mEqual(number a, number b, const coeffs)
static void nr2mInpMultM(number &a, number b, const coeffs r)
static BOOLEAN nr2mGreater(number a, number b, const coeffs r)
static void nr2mInpAddM(number &a, number b, const coeffs r)
static BOOLEAN nr2mIsZero(number a, const coeffs)
static number nr2mAddM(number a, number b, const coeffs r)
static const char * nr2mRead(const char *s, number *a, const coeffs r)
static BOOLEAN nr2mIsMOne(number a, const coeffs r)
static number nr2mSubM(number a, number b, const coeffs r)
static number nr2mDiv(number a, number b, const coeffs r)
static coeffs nr2mQuot1(number c, const coeffs r)