 |
My Project
UNKNOWN_GIT_VERSION
|
Go to the source code of this file.
|
#define | nr2mNegM(A, r) (number)((r->mod2mMask+1 - (unsigned long)(A)) & r->mod2mMask) |
|
#define | nr2mEqualM(A, B) ((A)==(B)) |
|
|
BOOLEAN | nr2mDBTest (number a, const char *f, const int l, const coeffs r) |
|
static number | nr2mMultM (number a, number b, const coeffs r) |
|
static number | nr2mAddM (number a, number b, const coeffs r) |
|
static number | nr2mSubM (number a, number b, const coeffs r) |
|
static char * | nr2mCoeffName (const coeffs cf) |
|
static void | nr2mCoeffWrite (const coeffs r, BOOLEAN) |
|
static BOOLEAN | nr2mCoeffIsEqual (const coeffs r, n_coeffType n, void *p) |
|
static char * | nr2mCoeffString (const coeffs r) |
|
static coeffs | nr2mQuot1 (number c, const coeffs r) |
|
static BOOLEAN | nr2mGreaterZero (number k, const coeffs r) |
|
static number | nr2mMult (number a, number b, const coeffs r) |
|
static number | nr2mAnn (number b, const coeffs r) |
|
static number | nr2mLcm (number a, number b, const coeffs) |
|
static number | nr2mGcd (number a, number b, const coeffs) |
|
static void | specialXGCD (unsigned long &s, unsigned long a, const coeffs r) |
|
static unsigned long | InvMod (unsigned long a, const coeffs r) |
|
static number | nr2mInversM (number c, const coeffs r) |
|
static number | nr2mInvers (number c, const coeffs r) |
|
static number | nr2mExtGcd (number a, number b, number *s, number *t, const coeffs r) |
|
static void | nr2mPower (number a, int i, number *result, const coeffs r) |
|
static number | nr2mInit (long i, const coeffs r) |
|
static long | nr2mInt (number &n, const coeffs r) |
|
static number | nr2mAdd (number a, number b, const coeffs r) |
|
static number | nr2mSub (number a, number b, const coeffs r) |
|
static BOOLEAN | nr2mIsUnit (number a, const coeffs) |
|
static number | nr2mGetUnit (number k, const coeffs) |
|
static BOOLEAN | nr2mIsZero (number a, const coeffs) |
|
static BOOLEAN | nr2mIsOne (number a, const coeffs) |
|
static BOOLEAN | nr2mIsMOne (number a, const coeffs r) |
|
static BOOLEAN | nr2mEqual (number a, number b, const coeffs) |
|
static number | nr2mDiv (number a, number b, const coeffs r) |
|
static BOOLEAN | nr2mDivBy (number a, number b, const coeffs r) |
|
static BOOLEAN | nr2mGreater (number a, number b, const coeffs r) |
|
static int | nr2mDivComp (number as, number bs, const coeffs) |
|
static number | nr2mMod (number a, number b, const coeffs r) |
|
static number | nr2mNeg (number c, const coeffs r) |
|
static number | nr2mMapMachineInt (number from, const coeffs, const coeffs dst) |
|
static number | nr2mMapProject (number from, const coeffs, const coeffs dst) |
|
number | nr2mMapZp (number from, const coeffs, const coeffs dst) |
|
static number | nr2mMapGMP (number from, const coeffs, const coeffs dst) |
|
static number | nr2mMapQ (number from, const coeffs src, const coeffs dst) |
|
static number | nr2mMapZ (number from, const coeffs src, const coeffs dst) |
|
static nMapFunc | nr2mSetMap (const coeffs src, const coeffs dst) |
|
static void | nr2mSetExp (int m, coeffs r) |
|
static void | nr2mInitExp (int m, coeffs r) |
|
static void | nr2mWrite (number a, const coeffs r) |
|
static const char * | nr2mEati (const char *s, int *i, const coeffs r) |
|
static const char * | nr2mRead (const char *s, number *a, const coeffs r) |
|
BOOLEAN | nr2mInitChar (coeffs r, void *p) |
|
◆ nr2mEqualM
#define nr2mEqualM |
( |
|
A, |
|
|
|
B |
|
) |
| ((A)==(B)) |
◆ nr2mNegM
#define nr2mNegM |
( |
|
A, |
|
|
|
r |
|
) |
| (number)((r->mod2mMask+1 - (unsigned long)(A)) & r->mod2mMask) |
◆ InvMod()
static unsigned long InvMod |
( |
unsigned long |
a, |
|
|
const coeffs |
r |
|
) |
| |
|
static |
◆ nr2mAdd()
static number nr2mAdd |
( |
number |
a, |
|
|
number |
b, |
|
|
const coeffs |
r |
|
) |
| |
|
static |
◆ nr2mAddM()
static number nr2mAddM |
( |
number |
a, |
|
|
number |
b, |
|
|
const coeffs |
r |
|
) |
| |
|
inlinestatic |
Definition at line 45 of file rmodulo2m.cc.
49 ((((
unsigned long) a) + ((
unsigned long)
b)) & r->mod2mMask);
◆ nr2mAnn()
Definition at line 577 of file rmodulo2m.cc.
580 if ((
unsigned long)
b == 0)
582 if ((
unsigned long)
b == 1)
584 unsigned long c = r->mod2mMask + 1;
586 return (number)(c / (
unsigned long)
b);
590 mpz_ptr cc = (mpz_ptr)
omAlloc(
sizeof(mpz_t));
591 mpz_init_set_ui(cc, r->mod2mMask); mpz_add_ui(cc, cc, 1);
592 mpz_div_ui(cc, cc, (
unsigned long)(
unsigned long)
b);
593 unsigned long s = mpz_get_ui(cc);
595 return (number)(
unsigned long)
s;
◆ nr2mCoeffIsEqual()
Definition at line 78 of file rmodulo2m.cc.
84 unsigned long mm=r->mod2mMask;
85 if (((mm+1)>>
m)==1L)
return TRUE;
◆ nr2mCoeffName()
Definition at line 63 of file rmodulo2m.cc.
66 static char n2mCoeffName_buf[30];
67 if (
cf->modExponent>32)
68 snprintf(n2mCoeffName_buf,21,
"ZZ/(bigint(2)^%lu)",
cf->modExponent);
70 snprintf(n2mCoeffName_buf,21,
"ZZ/(2^%lu)",
cf->modExponent);
71 return n2mCoeffName_buf;
◆ nr2mCoeffString()
◆ nr2mCoeffWrite()
◆ nr2mDBTest()
Definition at line 27 of file rmodulo2m.cc.
30 if (((
long)a<0L) || ((
long)a>(
long)r->mod2mMask))
32 Print(
"wrong mod 2^n number %ld at %s,%d\n",(
long)a,
f,
l);
◆ nr2mDiv()
static number nr2mDiv |
( |
number |
a, |
|
|
number |
b, |
|
|
const coeffs |
r |
|
) |
| |
|
static |
Definition at line 412 of file rmodulo2m.cc.
415 if ((
unsigned long)a == 0)
return (number)0;
416 else if ((
unsigned long)
b % 2 == 0)
418 if ((
unsigned long)
b != 0)
420 while (((
unsigned long)
b % 2 == 0) && ((
unsigned long)a % 2 == 0))
422 a = (number)((
unsigned long)a / 2);
423 b = (number)((
unsigned long)
b / 2);
426 if ((
unsigned long)
b % 2 == 0)
428 WerrorS(
"Division not possible, even by cancelling zero divisors.");
429 WerrorS(
"Result is integer division without remainder.");
430 return (number) ((
unsigned long) a / (
unsigned long)
b);
◆ nr2mDivBy()
Definition at line 440 of file rmodulo2m.cc.
445 unsigned long c = r->mod2mMask + 1;
447 return (c % (
unsigned long)
b) == 0;
452 c = (
unsigned long)
b;
455 if ((c % 2) != 0)
return FALSE;
◆ nr2mDivComp()
static int nr2mDivComp |
( |
number |
as, |
|
|
number |
bs, |
|
|
const |
coeffs |
|
) |
| |
|
static |
Definition at line 473 of file rmodulo2m.cc.
476 unsigned long a = (
unsigned long)as;
477 unsigned long b = (
unsigned long)bs;
479 while (a % 2 == 0 &&
b % 2 == 0)
◆ nr2mEati()
Definition at line 743 of file rmodulo2m.cc.
747 if (((*
s) >=
'0') && ((*
s) <=
'9'))
754 if ((*
i) >= (
MAX_INT_VAL / 10)) (*i) = (*i) & r->mod2mMask;
756 while (((*
s) >=
'0') && ((*
s) <=
'9'));
757 (*i) = (*i) & r->mod2mMask;
◆ nr2mEqual()
static BOOLEAN nr2mEqual |
( |
number |
a, |
|
|
number |
b, |
|
|
const |
coeffs |
|
) |
| |
|
static |
◆ nr2mExtGcd()
static number nr2mExtGcd |
( |
number |
a, |
|
|
number |
b, |
|
|
number * |
s, |
|
|
number * |
t, |
|
|
const coeffs |
r |
|
) |
| |
|
static |
Definition at line 294 of file rmodulo2m.cc.
297 unsigned long res = 0;
298 if ((
unsigned long)a == 0 && (
unsigned long)
b == 0)
return (number)1;
299 while ((
unsigned long)a % 2 == 0 && (
unsigned long)
b % 2 == 0)
301 a = (number)((
unsigned long)a / 2);
302 b = (number)((
unsigned long)
b / 2);
305 if ((
unsigned long)
b % 2 == 0)
309 return (number)((1L <<
res));
315 return (number)((1L <<
res));
◆ nr2mGcd()
static number nr2mGcd |
( |
number |
a, |
|
|
number |
b, |
|
|
const |
coeffs |
|
) |
| |
|
static |
Definition at line 181 of file rmodulo2m.cc.
184 unsigned long res = 0;
185 if ((
unsigned long)a == 0 && (
unsigned long)
b == 0)
return (number)1;
186 while ((
unsigned long)a % 2 == 0 && (
unsigned long)
b % 2 == 0)
188 a = (number)((
unsigned long)a / 2);
189 b = (number)((
unsigned long)
b / 2);
198 return (number)((1L <<
res));
◆ nr2mGetUnit()
static number nr2mGetUnit |
( |
number |
k, |
|
|
const |
coeffs |
|
) |
| |
|
static |
Definition at line 384 of file rmodulo2m.cc.
387 if (
k ==
NULL)
return (number)1;
388 unsigned long erg = (
unsigned long)
k;
389 while (erg % 2 == 0) erg = erg / 2;
◆ nr2mGreater()
◆ nr2mGreaterZero()
Definition at line 133 of file rmodulo2m.cc.
136 if ((
unsigned long)
k == 0)
return FALSE;
137 if ((
unsigned long)
k > ((r->mod2mMask >> 1) + 1))
return FALSE;
◆ nr2mInit()
Definition at line 338 of file rmodulo2m.cc.
341 if (
i == 0)
return (number)(
unsigned long)
i;
344 unsigned long j = (
unsigned long)1;
345 if (ii < 0) {
j = r->mod2mMask; ii = -ii; }
346 unsigned long k = (
unsigned long)ii;
347 k =
k & r->mod2mMask;
349 return (number)
nr2mMult((number)
j, (number)
k, r);
◆ nr2mInitChar()
Definition at line 781 of file rmodulo2m.cc.
796 mpz_init_set_si (r->modBase, 2L);
798 mpz_init (r->modNumber);
799 mpz_pow_ui (r->modNumber, r->modBase, r->modExponent);
802 r->ch = (int)r->mod2mMask + 1;
840 r->has_simple_Alloc=
TRUE;
◆ nr2mInitExp()
static void nr2mInitExp |
( |
int |
m, |
|
|
coeffs |
r |
|
) |
| |
|
static |
Definition at line 730 of file rmodulo2m.cc.
735 WarnS(
"nr2mInitExp unexpectedly called with m = 1 (we continue with Z/2^2");
◆ nr2mInt()
Definition at line 355 of file rmodulo2m.cc.
358 unsigned long nn = (
unsigned long)n;
359 unsigned long l = r->mod2mMask >> 1;
l++;
360 if ((
unsigned long)nn >
l)
361 return (
long)((
unsigned long)nn - r->mod2mMask - 1);
363 return (
long)((
unsigned long)nn);
◆ nr2mInvers()
Definition at line 280 of file rmodulo2m.cc.
283 if ((
unsigned long)c % 2 == 0)
285 WerrorS(
"division by zero divisor");
◆ nr2mInversM()
◆ nr2mIsMOne()
Definition at line 402 of file rmodulo2m.cc.
405 return ((r->mod2mMask == (
unsigned long)a) &&(1L!=(
long)a));
◆ nr2mIsOne()
Definition at line 397 of file rmodulo2m.cc.
400 return 1 == (
unsigned long)a;
◆ nr2mIsUnit()
Definition at line 379 of file rmodulo2m.cc.
382 return ((
unsigned long)a % 2 == 1);
◆ nr2mIsZero()
Definition at line 392 of file rmodulo2m.cc.
395 return 0 == (
unsigned long)a;
◆ nr2mLcm()
static number nr2mLcm |
( |
number |
a, |
|
|
number |
b, |
|
|
const |
coeffs |
|
) |
| |
|
static |
Definition at line 158 of file rmodulo2m.cc.
161 unsigned long res = 0;
162 if ((
unsigned long)a == 0) a = (number) 1;
163 if ((
unsigned long)
b == 0)
b = (number) 1;
164 while ((
unsigned long)a % 2 == 0)
166 a = (number)((
unsigned long)a / 2);
167 if ((
unsigned long)
b % 2 == 0)
b = (number)((
unsigned long)
b / 2);
170 while ((
unsigned long)
b % 2 == 0)
172 b = (number)((
unsigned long)
b / 2);
175 return (number)(1L <<
res);
◆ nr2mMapGMP()
Definition at line 629 of file rmodulo2m.cc.
634 mpz_ptr
k = (mpz_ptr)
omAlloc(
sizeof(mpz_t));
635 mpz_init_set_ui(
k, dst->mod2mMask);
637 mpz_and(erg, (mpz_ptr)from,
k);
638 number
res = (number) mpz_get_ui(erg);
◆ nr2mMapMachineInt()
Definition at line 606 of file rmodulo2m.cc.
609 unsigned long i = ((
unsigned long)from) % (dst->mod2mMask + 1) ;
◆ nr2mMapProject()
Definition at line 612 of file rmodulo2m.cc.
615 unsigned long i = ((
unsigned long)from) % (dst->mod2mMask + 1);
◆ nr2mMapQ()
◆ nr2mMapZ()
◆ nr2mMapZp()
Definition at line 618 of file rmodulo2m.cc.
621 unsigned long j = (
unsigned long)1;
622 long ii = (long)from;
623 if (ii < 0) {
j = dst->mod2mMask; ii = -ii; }
624 unsigned long i = (
unsigned long)ii;
625 i =
i & dst->mod2mMask;
627 return (number)
nr2mMult((number)
i, (number)
j, dst);
◆ nr2mMod()
static number nr2mMod |
( |
number |
a, |
|
|
number |
b, |
|
|
const coeffs |
r |
|
) |
| |
|
static |
Definition at line 500 of file rmodulo2m.cc.
524 assume((
unsigned long)
b != 0);
526 unsigned long b_div = (
unsigned long)
b;
534 unsigned long rr = 0;
535 while ((g < r->mod2mMask ) && (b_div > 0) && (b_div % 2 == 0))
541 if (
g != 1) rr = (
unsigned long)a %
g;
◆ nr2mMult()
static number nr2mMult |
( |
number |
a, |
|
|
number |
b, |
|
|
const coeffs |
r |
|
) |
| |
|
static |
Definition at line 143 of file rmodulo2m.cc.
147 if (((
unsigned long)a == 0) || ((
unsigned long)
b == 0))
◆ nr2mMultM()
static number nr2mMultM |
( |
number |
a, |
|
|
number |
b, |
|
|
const coeffs |
r |
|
) |
| |
|
inlinestatic |
Definition at line 39 of file rmodulo2m.cc.
43 ((((
unsigned long) a) * ((
unsigned long)
b)) & r->mod2mMask);
◆ nr2mNeg()
Definition at line 598 of file rmodulo2m.cc.
601 if ((
unsigned long)c == 0)
return c;
◆ nr2mPower()
static void nr2mPower |
( |
number |
a, |
|
|
int |
i, |
|
|
number * |
result, |
|
|
const coeffs |
r |
|
) |
| |
|
static |
◆ nr2mQuot1()
Definition at line 94 of file rmodulo2m.cc.
98 long ch = r->cfInt(c, r);
100 mpz_init_set(a, r->modNumber);
101 mpz_init_set_ui(
b, ch);
106 if(mpz_cmp_ui(
gcd, 1) == 0)
108 WerrorS(
"constant in q-ideal is coprime to modulus in ground ring");
109 WerrorS(
"Unable to create qring!");
112 if(mpz_cmp_ui(
gcd, 2) == 0)
120 mpz_init(baseTokNew);
121 mpz_set(baseTokNew, r->modBase);
122 while(mpz_cmp(
gcd, baseTokNew) > 0)
125 mpz_mul(baseTokNew, baseTokNew, r->modBase);
127 mpz_clear(baseTokNew);
◆ nr2mRead()
Definition at line 762 of file rmodulo2m.cc.
775 *a = (number)(
long)z;
777 *a =
nr2mDiv((number)(
long)z,(number)(
long)n,r);
◆ nr2mSetExp()
static void nr2mSetExp |
( |
int |
m, |
|
|
coeffs |
r |
|
) |
| |
|
static |
Definition at line 712 of file rmodulo2m.cc.
721 for (
int i = 1;
i <
m;
i++) r->mod2mMask = (r->mod2mMask << 1) + 1;
◆ nr2mSetMap()
Definition at line 665 of file rmodulo2m.cc.
669 && (src->mod2mMask == dst->mod2mMask))
674 && (src->mod2mMask < dst->mod2mMask))
679 && (src->mod2mMask > dst->mod2mMask))
703 if (mpz_divisible_2exp_p(src->modNumber,dst->modExponent))
◆ nr2mSub()
static number nr2mSub |
( |
number |
a, |
|
|
number |
b, |
|
|
const coeffs |
r |
|
) |
| |
|
static |
◆ nr2mSubM()
static number nr2mSubM |
( |
number |
a, |
|
|
number |
b, |
|
|
const coeffs |
r |
|
) |
| |
|
inlinestatic |
Definition at line 51 of file rmodulo2m.cc.
54 return (number)((
unsigned long)a < (
unsigned long)
b ?
55 r->mod2mMask+1 - (
unsigned long)
b + (
unsigned long)a:
56 (
unsigned long)a - (
unsigned long)
b);
◆ nr2mWrite()
◆ specialXGCD()
static void specialXGCD |
( |
unsigned long & |
s, |
|
|
unsigned long |
a, |
|
|
const coeffs |
r |
|
) |
| |
|
static |
Definition at line 205 of file rmodulo2m.cc.
208 mpz_ptr u = (mpz_ptr)
omAlloc(
sizeof(mpz_t));
209 mpz_init_set_ui(u, a);
210 mpz_ptr u0 = (mpz_ptr)
omAlloc(
sizeof(mpz_t));
212 mpz_ptr u1 = (mpz_ptr)
omAlloc(
sizeof(mpz_t));
213 mpz_init_set_ui(u1, 1);
214 mpz_ptr u2 = (mpz_ptr)
omAlloc(
sizeof(mpz_t));
216 mpz_ptr
v = (mpz_ptr)
omAlloc(
sizeof(mpz_t));
217 mpz_init_set_ui(
v, r->mod2mMask);
219 mpz_ptr v0 = (mpz_ptr)
omAlloc(
sizeof(mpz_t));
221 mpz_ptr v1 = (mpz_ptr)
omAlloc(
sizeof(mpz_t));
223 mpz_ptr v2 = (mpz_ptr)
omAlloc(
sizeof(mpz_t));
224 mpz_init_set_ui(v2, 1);
225 mpz_ptr q = (mpz_ptr)
omAlloc(
sizeof(mpz_t));
227 mpz_ptr rr = (mpz_ptr)
omAlloc(
sizeof(mpz_t));
238 mpz_mul(u2, u2, q); mpz_sub(u2, u1, u2);
239 mpz_mul(v2, v2, q); mpz_sub(v2, v1, v2);
247 mpz_add_ui(u1, u1, r->mod2mMask);
248 mpz_add_ui(u1, u1, 1);
◆ gmp_nrz_bin
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
(mpz_ptr), see rmodulon,h
static number nr2mMapProject(number from, const coeffs, const coeffs dst)
static BOOLEAN nr2mGreaterZero(number k, const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
static number nr2mNeg(number c, const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_Z(const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_2toM(const coeffs r)
static number nr2mLcm(number a, number b, const coeffs)
static number nr2mSub(number a, number b, const coeffs r)
static number nr2mAdd(number a, number b, const coeffs r)
static int nr2mDivComp(number as, number bs, const coeffs)
only used if HAVE_RINGS is defined
static number nr2mMult(number a, number b, const coeffs r)
static number nr2mInvers(number c, const coeffs r)
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
static BOOLEAN nr2mIsUnit(number a, const coeffs)
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
static void nr2mInitExp(int m, coeffs r)
static number nr2mAnn(number b, const coeffs r)
static const char * nr2mRead(const char *s, number *a, const coeffs r)
static number nr2mGcd(number a, number b, const coeffs)
static number nr2mInit(long i, const coeffs r)
static void nr2mCoeffWrite(const coeffs r, BOOLEAN)
static number nr2mMapQ(number from, const coeffs src, const coeffs dst)
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
static void specialXGCD(unsigned long &s, unsigned long a, const coeffs r)
static BOOLEAN nr2mIsMOne(number a, const coeffs r)
static number nr2mSubM(number a, number b, const coeffs r)
static void nr2mSetExp(int m, coeffs r)
static char * nr2mCoeffName(const coeffs cf)
static unsigned long InvMod(unsigned long a, const coeffs r)
void PrintS(const char *s)
static number nr2mDiv(number a, number b, const coeffs r)
static const char * nr2mEati(const char *s, int *i, const coeffs r)
static number nr2mMod(number a, number b, const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_PtoM(const coeffs r)
static number nr2mMultM(number a, number b, const coeffs r)
static number nr2mGetUnit(number k, const coeffs)
number nr2mMapZp(number from, const coeffs, const coeffs dst)
static nMapFunc nr2mSetMap(const coeffs src, const coeffs dst)
static number nr2mMapZ(number from, const coeffs src, const coeffs dst)
static number nr2mMapMachineInt(number from, const coeffs, const coeffs dst)
static coeffs nr2mQuot1(number c, const coeffs r)
static long nr2mInt(number &n, const coeffs r)
static number nr2mExtGcd(number a, number b, number *s, number *t, const coeffs r)
static number nr2mMapGMP(number from, const coeffs, const coeffs dst)
static BOOLEAN nr2mIsZero(number a, const coeffs)
void WerrorS(const char *s)
static number nr2mInversM(number c, const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_Zn(const coeffs r)
static BOOLEAN nr2mCoeffIsEqual(const coeffs r, n_coeffType n, void *p)
static void nr2mWrite(number a, const coeffs r)
static char * nr2mCoeffString(const coeffs r)
static BOOLEAN nr2mGreater(number a, number b, const coeffs r)
const Variable & v
< [in] a sqrfree bivariate poly
static BOOLEAN nr2mIsOne(number a, const coeffs)
static BOOLEAN nr2mDivBy(number a, number b, const coeffs r)
const CanonicalForm int s
BOOLEAN nr2mDBTest(number a, const char *f, const int l, const coeffs r)
static BOOLEAN nr2mEqual(number a, number b, const coeffs)
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
static number nr2mAddM(number a, number b, const coeffs r)
static void nr2mPower(number a, int i, number *result, const coeffs r)
void nlGMP(number &i, mpz_t n, const coeffs r)
(), see rinteger.h, new impl.