28 if ((((
long)a<0L) || ((
long)a>(
long)r->mod2mMask))
29 && (r->mod2mMask!= ~0
UL))
31 Print(
"wrong mod 2^n number %ld (m:%ld) at %s,%d\n",(
long)a,(
long)r->mod2mMask,
f,
l);
42 ((((
unsigned long) a) * ((
unsigned long)
b)) & r->mod2mMask);
48 ((((
unsigned long) a) * ((
unsigned long)
b)) & r->mod2mMask);
54 ((((
unsigned long) a) + ((
unsigned long)
b)) & r->mod2mMask);
60 ((((
unsigned long) a) + ((
unsigned long)
b)) & r->mod2mMask);
65 return (
number)((
unsigned long)a < (
unsigned long)
b ?
66 r->mod2mMask+1 - (
unsigned long)
b + (
unsigned long)a:
67 (
unsigned long)a - (
unsigned long)
b);
70#define nr2mNegM(A,r) (number)((r->mod2mMask+1 - (unsigned long)(A)) & r->mod2mMask)
71#define nr2mEqualM(A,B) ((A)==(B))
78 if (
cf->modExponent>32)
90 unsigned long mm=r->mod2mMask;
91 if (((
mm+1)>>
m)==1L)
return TRUE;
99 long ch = r->cfInt(c, r);
109 WerrorS(
"constant in q-ideal is coprime to modulus in ground ring");
110 WerrorS(
"Unable to create qring!");
137 if ((
unsigned long)
k == 0)
return FALSE;
138 if ((
unsigned long)
k > ((r->mod2mMask >> 1) + 1))
return FALSE;
148 if (((
unsigned long)a == 0) || ((
unsigned long)
b == 0))
158 if (((
unsigned long)a == 0) || ((
unsigned long)
b == 0))
171 unsigned long res = 0;
172 if ((
unsigned long)a == 0) a = (
number) 1;
173 if ((
unsigned long)
b == 0)
b = (
number) 1;
174 while ((
unsigned long)a % 2 == 0)
176 a = (
number)((
unsigned long)a / 2);
177 if ((
unsigned long)
b % 2 == 0)
b = (
number)((
unsigned long)
b / 2);
180 while ((
unsigned long)
b % 2 == 0)
194 unsigned long res = 0;
195 if ((
unsigned long)a == 0 && (
unsigned long)
b == 0)
return (
number)1;
196 while ((
unsigned long)a % 2 == 0 && (
unsigned long)
b % 2 == 0)
198 a = (
number)((
unsigned long)a / 2);
276 assume((
unsigned long)a % 2 != 0);
284 assume((
unsigned long)c % 2 != 0);
293 if ((
unsigned long)c % 2 == 0)
295 WerrorS(
"division by zero divisor");
307 unsigned long res = 0;
308 if ((
unsigned long)a == 0 && (
unsigned long)
b == 0)
return (
number)1;
309 while ((
unsigned long)a % 2 == 0 && (
unsigned long)
b % 2 == 0)
311 a = (
number)((
unsigned long)a / 2);
315 if ((
unsigned long)
b % 2 == 0)
333 *(
unsigned long *)
result = 1;
354 unsigned long j = (
unsigned long)1;
355 if (
ii < 0) {
j = r->mod2mMask;
ii = -
ii; }
356 unsigned long k = (
unsigned long)
ii;
357 k =
k & r->mod2mMask;
368 unsigned long nn = (
unsigned long)n;
369 unsigned long l = r->mod2mMask >> 1;
l++;
370 if ((
unsigned long)
nn >
l)
371 return (
long)((
unsigned long)
nn - r->mod2mMask - 1);
373 return (
long)((
unsigned long)
nn);
398 return ((
unsigned long)a % 2 == 1);
404 unsigned long erg = (
unsigned long)
k;
411 return 0 == (
unsigned long)a;
416 return 1 == (
unsigned long)a;
421 return ((r->mod2mMask == (
unsigned long)a) &&(1L!=(
long)a));
431 if ((
unsigned long)a == 0)
return (
number)0;
432 else if ((
unsigned long)
b % 2 == 0)
434 if ((
unsigned long)
b != 0)
436 while (((
unsigned long)
b % 2 == 0) && ((
unsigned long)a % 2 == 0))
438 a = (
number)((
unsigned long)a / 2);
447 else if ((
unsigned long)
b % 2 == 0)
449 WerrorS(
"Division not possible, even by cancelling zero divisors.");
450 WerrorS(
"Result is integer division without remainder.");
451 return (
number) ((
unsigned long) a / (
unsigned long)
b);
466 unsigned long c = r->mod2mMask + 1;
468 return (c % (
unsigned long)
b) == 0;
473 c = (
unsigned long)
b;
476 if ((c % 2) != 0)
return FALSE;
497 unsigned long a = (
unsigned long)
as;
498 unsigned long b = (
unsigned long)
bs;
500 while (a % 2 == 0 &&
b % 2 == 0)
545 assume((
unsigned long)
b != 0);
555 unsigned long rr = 0;
562 if (
g != 1)
rr = (
unsigned long)a %
g;
570 if ((
unsigned long)a == 0)
572 if ((
unsigned long)
b == 0)
574 if ((
unsigned long)
b == 1)
576 unsigned long c = r->mod2mMask + 1;
592 if ((
unsigned long)
b == 0)
594 return (
number)((
unsigned long) a / (
unsigned long)
b);
601 if ((
unsigned long)
b == 0)
603 if ((
unsigned long)
b == 1)
605 unsigned long c = r->mod2mMask + 1;
622 if ((
unsigned long)c == 0)
return c;
630 unsigned long i = ((
unsigned long)from) % (
dst->mod2mMask + 1) ;
636 unsigned long i = ((
unsigned long)from) % (
dst->mod2mMask + 1);
642 unsigned long j = (
unsigned long)1;
645 unsigned long i = (
unsigned long)
ii;
646 i =
i &
dst->mod2mMask;
689 && (src->mod2mMask <
dst->mod2mMask))
694 && (src->mod2mMask >
dst->mod2mMask))
736 for (
int i = 1;
i <
m;
i++) r->mod2mMask = (r->mod2mMask << 1) + 1;
750 WarnS(
"nr2mInitExp unexpectedly called with m = 1 (we continue with Z/2^2");
762 if (((*
s) >=
'0') && ((*
s) <=
'9'))
769 if ((*
i) >= (
MAX_INT_VAL / 10)) (*i) = (*i) & r->mod2mMask;
771 while (((*
s) >=
'0') && ((*
s) <=
'9'));
772 (*i) = (*i) & r->mod2mMask;
813 mpz_pow_ui (r->modNumber, r->modBase, r->modExponent);
816 r->ch = (
int)r->mod2mMask + 1;
855 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)