Macros | Functions | Variables
rmodulo2m.cc File Reference
#include <misc/auxiliary.h>
#include <omalloc/omalloc.h>
#include <misc/mylimits.h>
#include <reporter/reporter.h>
#include "si_gmp.h"
#include "coeffs.h"
#include "numbers.h"
#include "longrat.h"
#include "mpr_complex.h"
#include "rmodulo2m.h"
#include "rmodulon.h"
#include <string.h>

Go to the source code of this file.

Macros

#define nr2mNegM(A, r)   (number)((r->mod2mMask - (unsigned long)(A) + 1) & r->mod2mMask)
 
#define nr2mEqualM(A, B)   ((A)==(B))
 

Functions

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 BOOLEAN nr2mDBTest (number a, const char *, const int, const 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)
 

Variables

omBin gmp_nrz_bin
 

Macro Definition Documentation

§ nr2mEqualM

#define nr2mEqualM (   A,
  B 
)    ((A)==(B))

Definition at line 47 of file rmodulo2m.cc.

§ nr2mNegM

#define nr2mNegM (   A,
  r 
)    (number)((r->mod2mMask - (unsigned long)(A) + 1) & r->mod2mMask)

Definition at line 46 of file rmodulo2m.cc.

Function Documentation

§ InvMod()

static unsigned long InvMod ( unsigned long  a,
const coeffs  r 
)
static

Definition at line 249 of file rmodulo2m.cc.

250 {
251  assume((unsigned long)a % 2 != 0);
252  unsigned long s;
253  specialXGCD(s, a, r);
254  return s;
255 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
const poly a
Definition: syzextra.cc:212
#define assume(x)
Definition: mod2.h:394
static void specialXGCD(unsigned long &s, unsigned long a, const coeffs r)
Definition: rmodulo2m.cc:191

§ nr2mAdd()

static number nr2mAdd ( number  a,
number  b,
const coeffs  r 
)
static

Definition at line 351 of file rmodulo2m.cc.

352 {
353  return nr2mAddM(a, b, r);
354 }
const poly a
Definition: syzextra.cc:212
static number nr2mAddM(number a, number b, const coeffs r)
Definition: rmodulo2m.cc:33
const poly b
Definition: syzextra.cc:213

§ nr2mAddM()

static number nr2mAddM ( number  a,
number  b,
const coeffs  r 
)
inlinestatic

Definition at line 33 of file rmodulo2m.cc.

34 {
35  return (number)
36  ((((unsigned long) a) + ((unsigned long) b)) & ((unsigned long)r->mod2mMask));
37 }
const poly a
Definition: syzextra.cc:212
const poly b
Definition: syzextra.cc:213

§ nr2mAnn()

static number nr2mAnn ( number  b,
const coeffs  r 
)
static

Definition at line 557 of file rmodulo2m.cc.

558 {
559  if ((unsigned long)b == 0)
560  return NULL;
561  if ((unsigned long)b == 1)
562  return NULL;
563  unsigned long c = r->mod2mMask + 1;
564  if (c != 0) /* i.e., if no overflow */
565  return (number)(c / (unsigned long)b);
566  else
567  {
568  /* overflow: c = 2^32 resp. 2^64, depending on platform */
569  mpz_ptr cc = (mpz_ptr)omAlloc(sizeof(mpz_t));
570  mpz_init_set_ui(cc, r->mod2mMask); mpz_add_ui(cc, cc, 1);
571  mpz_div_ui(cc, cc, (unsigned long)(unsigned long)b);
572  unsigned long s = mpz_get_ui(cc);
573  mpz_clear(cc); omFree((ADDRESS)cc);
574  return (number)(unsigned long)s;
575  }
576 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
void * ADDRESS
Definition: auxiliary.h:115
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define omFree(addr)
Definition: omAllocDecl.h:261
#define NULL
Definition: omList.c:10
const poly b
Definition: syzextra.cc:213

§ nr2mCoeffIsEqual()

static BOOLEAN nr2mCoeffIsEqual ( const coeffs  r,
n_coeffType  n,
void *  p 
)
static

Definition at line 64 of file rmodulo2m.cc.

65 {
66  if (n==n_Z2m)
67  {
68  int m=(int)(long)(p);
69  unsigned long mm=r->mod2mMask;
70  if (((mm+1)>>m)==1L) return TRUE;
71  }
72  return FALSE;
73 }
only used if HAVE_RINGS is defined
Definition: coeffs.h:46
#define FALSE
Definition: auxiliary.h:94
return P p
Definition: myNF.cc:203
#define TRUE
Definition: auxiliary.h:98
int m
Definition: cfEzgcd.cc:119

§ nr2mCoeffName()

static char* nr2mCoeffName ( const coeffs  cf)
static

Definition at line 51 of file rmodulo2m.cc.

52 {
53  static char n2mCoeffName_buf[22];
54  snprintf(n2mCoeffName_buf,21,"ZZ/(2^%lu)",cf->modExponent);
55  return n2mCoeffName_buf;
56 }

§ nr2mCoeffString()

static char* nr2mCoeffString ( const coeffs  r)
static

Definition at line 75 of file rmodulo2m.cc.

76 {
77  // r->modExponent <=bitsize(long)
78  char* s = (char*) omAlloc(11+11);
79  sprintf(s,"ZZ/(2^%lu)",r->modExponent);
80  return s;
81 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define omAlloc(size)
Definition: omAllocDecl.h:210

§ nr2mCoeffWrite()

static void nr2mCoeffWrite ( const coeffs  r,
BOOLEAN   
)
static

Definition at line 58 of file rmodulo2m.cc.

59 {
60  PrintS("// coeff. ring is : ");
61  Print("Z/2^%lu\n", r->modExponent);
62 }
#define Print
Definition: emacs.cc:83
void PrintS(const char *s)
Definition: reporter.cc:284

§ nr2mDBTest()

static BOOLEAN nr2mDBTest ( number  a,
const char *  ,
const int  ,
const coeffs  r 
)
static

Definition at line 716 of file rmodulo2m.cc.

717 {
718  //if ((unsigned long)a < 0) return FALSE; // is unsigned!
719  if (((unsigned long)a & r->mod2mMask) != (unsigned long)a) return FALSE;
720  return TRUE;
721 }
const poly a
Definition: syzextra.cc:212
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98

§ nr2mDiv()

static number nr2mDiv ( number  a,
number  b,
const coeffs  r 
)
static

Definition at line 394 of file rmodulo2m.cc.

395 {
396  if ((unsigned long)a == 0) return (number)0;
397  else if ((unsigned long)b % 2 == 0)
398  {
399  if ((unsigned long)b != 0)
400  {
401  while (((unsigned long)b % 2 == 0) && ((unsigned long)a % 2 == 0))
402  {
403  a = (number)((unsigned long)a / 2);
404  b = (number)((unsigned long)b / 2);
405  }
406  }
407  if ((unsigned long)b % 2 == 0)
408  {
409  WerrorS("Division not possible, even by cancelling zero divisors.");
410  WerrorS("Result is integer division without remainder.");
411  return (number) ((unsigned long) a / (unsigned long) b);
412  }
413  }
414  return (number)nr2mMult(a, nr2mInversM(b,r),r);
415 }
const poly a
Definition: syzextra.cc:212
void WerrorS(const char *s)
Definition: feFopen.cc:24
static number nr2mInversM(number c, const coeffs r)
Definition: rmodulo2m.cc:257
static number nr2mMult(number a, number b, const coeffs r)
Definition: rmodulo2m.cc:132
const poly b
Definition: syzextra.cc:213

§ nr2mDivBy()

static BOOLEAN nr2mDivBy ( number  a,
number  b,
const coeffs  r 
)
static

Definition at line 420 of file rmodulo2m.cc.

421 {
422  if (a == NULL)
423  {
424  unsigned long c = r->mod2mMask + 1;
425  if (c != 0) /* i.e., if no overflow */
426  return (c % (unsigned long)b) == 0;
427  else
428  {
429  /* overflow: we need to check whether b
430  is zero or a power of 2: */
431  c = (unsigned long)b;
432  while (c != 0)
433  {
434  if ((c % 2) != 0) return FALSE;
435  c = c >> 1;
436  }
437  return TRUE;
438  }
439  }
440  else
441  {
442  number n = nr2mGcd(a, b, r);
443  n = nr2mDiv(b, n, r);
444  return nr2mIsUnit(n, r);
445  }
446 }
const poly a
Definition: syzextra.cc:212
#define FALSE
Definition: auxiliary.h:94
static number nr2mDiv(number a, number b, const coeffs r)
Definition: rmodulo2m.cc:394
#define TRUE
Definition: auxiliary.h:98
#define NULL
Definition: omList.c:10
static BOOLEAN nr2mIsUnit(number a, const coeffs)
Definition: rmodulo2m.cc:361
static number nr2mGcd(number a, number b, const coeffs)
Definition: rmodulo2m.cc:167
const poly b
Definition: syzextra.cc:213

§ nr2mDivComp()

static int nr2mDivComp ( number  as,
number  bs,
const coeffs   
)
static

Definition at line 453 of file rmodulo2m.cc.

454 {
455  unsigned long a = (unsigned long)as;
456  unsigned long b = (unsigned long)bs;
457  assume(a != 0 && b != 0);
458  while (a % 2 == 0 && b % 2 == 0)
459  {
460  a = a / 2;
461  b = b / 2;
462  }
463  if (a % 2 == 0)
464  {
465  return -1;
466  }
467  else
468  {
469  if (b % 2 == 1)
470  {
471  return 2;
472  }
473  else
474  {
475  return 1;
476  }
477  }
478 }
const poly a
Definition: syzextra.cc:212
#define assume(x)
Definition: mod2.h:394
const poly b
Definition: syzextra.cc:213

§ nr2mEati()

static const char* nr2mEati ( const char *  s,
int *  i,
const coeffs  r 
)
static

Definition at line 730 of file rmodulo2m.cc.

731 {
732 
733  if (((*s) >= '0') && ((*s) <= '9'))
734  {
735  (*i) = 0;
736  do
737  {
738  (*i) *= 10;
739  (*i) += *s++ - '0';
740  if ((*i) >= (MAX_INT_VAL / 10)) (*i) = (*i) & r->mod2mMask;
741  }
742  while (((*s) >= '0') && ((*s) <= '9'));
743  (*i) = (*i) & r->mod2mMask;
744  }
745  else (*i) = 1;
746  return s;
747 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
const int MAX_INT_VAL
Definition: mylimits.h:12
int i
Definition: cfEzgcd.cc:123

§ nr2mEqual()

static BOOLEAN nr2mEqual ( number  a,
number  b,
const coeffs   
)
static

Definition at line 389 of file rmodulo2m.cc.

390 {
391  return (a == b);
392 }
const poly a
Definition: syzextra.cc:212
const poly b
Definition: syzextra.cc:213

§ nr2mExtGcd()

static number nr2mExtGcd ( number  a,
number  b,
number *  s,
number *  t,
const coeffs  r 
)
static

Definition at line 280 of file rmodulo2m.cc.

281 {
282  unsigned long res = 0;
283  if ((unsigned long)a == 0 && (unsigned long)b == 0) return (number)1;
284  while ((unsigned long)a % 2 == 0 && (unsigned long)b % 2 == 0)
285  {
286  a = (number)((unsigned long)a / 2);
287  b = (number)((unsigned long)b / 2);
288  res++;
289  }
290  if ((unsigned long)b % 2 == 0)
291  {
292  *t = NULL;
293  *s = nr2mInvers(a,r);
294  return (number)((1L << res)); // * (unsigned long) a); // (2**res)*a a is a unit
295  }
296  else
297  {
298  *s = NULL;
299  *t = nr2mInvers(b,r);
300  return (number)((1L << res)); // * (unsigned long) b); // (2**res)*b b is a unit
301  }
302 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
const poly a
Definition: syzextra.cc:212
poly res
Definition: myNF.cc:322
#define NULL
Definition: omList.c:10
static number nr2mInvers(number c, const coeffs r)
Definition: rmodulo2m.cc:266
const poly b
Definition: syzextra.cc:213

§ nr2mGcd()

static number nr2mGcd ( number  a,
number  b,
const coeffs   
)
static

Definition at line 167 of file rmodulo2m.cc.

168 {
169  unsigned long res = 0;
170  if ((unsigned long)a == 0 && (unsigned long)b == 0) return (number)1;
171  while ((unsigned long)a % 2 == 0 && (unsigned long)b % 2 == 0)
172  {
173  a = (number)((unsigned long)a / 2);
174  b = (number)((unsigned long)b / 2);
175  res++;
176  }
177 // if ((unsigned long)b % 2 == 0)
178 // {
179 // return (number)((1L << res)); // * (unsigned long) a); // (2**res)*a a is a unit
180 // }
181 // else
182 // {
183  return (number)((1L << res)); // * (unsigned long) b); // (2**res)*b b is a unit
184 // }
185 }
const poly a
Definition: syzextra.cc:212
poly res
Definition: myNF.cc:322
const poly b
Definition: syzextra.cc:213

§ nr2mGetUnit()

static number nr2mGetUnit ( number  k,
const coeffs   
)
static

Definition at line 366 of file rmodulo2m.cc.

367 {
368  if (k == NULL) return (number)1;
369  unsigned long erg = (unsigned long)k;
370  while (erg % 2 == 0) erg = erg / 2;
371  return (number)erg;
372 }
int k
Definition: cfEzgcd.cc:93
#define NULL
Definition: omList.c:10

§ nr2mGreater()

static BOOLEAN nr2mGreater ( number  a,
number  b,
const coeffs  r 
)
static

Definition at line 448 of file rmodulo2m.cc.

449 {
450  return nr2mDivBy(a, b,r);
451 }
const poly a
Definition: syzextra.cc:212
static BOOLEAN nr2mDivBy(number a, number b, const coeffs r)
Definition: rmodulo2m.cc:420
const poly b
Definition: syzextra.cc:213

§ nr2mGreaterZero()

static BOOLEAN nr2mGreaterZero ( number  k,
const coeffs  r 
)
static

Definition at line 122 of file rmodulo2m.cc.

123 {
124  if ((unsigned long)k == 0) return FALSE;
125  if ((unsigned long)k > ((r->mod2mMask >> 1) + 1)) return FALSE;
126  return TRUE;
127 }
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
int k
Definition: cfEzgcd.cc:93

§ nr2mInit()

static number nr2mInit ( long  i,
const coeffs  r 
)
static

Definition at line 324 of file rmodulo2m.cc.

325 {
326  if (i == 0) return (number)(unsigned long)i;
327 
328  long ii = i;
329  unsigned long j = (unsigned long)1;
330  if (ii < 0) { j = r->mod2mMask; ii = -ii; }
331  unsigned long k = (unsigned long)ii;
332  k = k & r->mod2mMask;
333  /* now we have: i = j * k mod 2^m */
334  return (number)nr2mMult((number)j, (number)k, r);
335 }
int k
Definition: cfEzgcd.cc:93
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
static number nr2mMult(number a, number b, const coeffs r)
Definition: rmodulo2m.cc:132

§ nr2mInitChar()

BOOLEAN nr2mInitChar ( coeffs  r,
void *  p 
)

Definition at line 768 of file rmodulo2m.cc.

769 {
770  assume( getCoeffType(r) == n_Z2m );
771  nr2mInitExp((int)(long)(p), r);
772 
773  r->is_field=FALSE;
774  r->is_domain=FALSE;
775  r->rep=n_rep_int;
776 
777  //r->cfKillChar = ndKillChar; /* dummy*/
778  r->nCoeffIsEqual = nr2mCoeffIsEqual;
779  r->cfCoeffString = nr2mCoeffString;
780 
781  r->modBase = (mpz_ptr) omAllocBin (gmp_nrz_bin);
782  mpz_init_set_si (r->modBase, 2L);
783  r->modNumber= (mpz_ptr) omAllocBin (gmp_nrz_bin);
784  mpz_init (r->modNumber);
785  mpz_pow_ui (r->modNumber, r->modBase, r->modExponent);
786 
787  /* next cast may yield an overflow as mod2mMask is an unsigned long */
788  r->ch = (int)r->mod2mMask + 1;
789 
790  r->cfInit = nr2mInit;
791  //r->cfCopy = ndCopy;
792  r->cfInt = nr2mInt;
793  r->cfAdd = nr2mAdd;
794  r->cfSub = nr2mSub;
795  r->cfMult = nr2mMult;
796  r->cfDiv = nr2mDiv;
797  r->cfAnn = nr2mAnn;
798  r->cfIntMod = nr2mMod;
799  r->cfExactDiv = nr2mDiv;
800  r->cfInpNeg = nr2mNeg;
801  r->cfInvers = nr2mInvers;
802  r->cfDivBy = nr2mDivBy;
803  r->cfDivComp = nr2mDivComp;
804  r->cfGreater = nr2mGreater;
805  r->cfEqual = nr2mEqual;
806  r->cfIsZero = nr2mIsZero;
807  r->cfIsOne = nr2mIsOne;
808  r->cfIsMOne = nr2mIsMOne;
809  r->cfGreaterZero = nr2mGreaterZero;
810  r->cfWriteLong = nr2mWrite;
811  r->cfRead = nr2mRead;
812  r->cfPower = nr2mPower;
813  r->cfSetMap = nr2mSetMap;
814 // r->cfNormalize = ndNormalize; // default
815  r->cfLcm = nr2mLcm;
816  r->cfGcd = nr2mGcd;
817  r->cfIsUnit = nr2mIsUnit;
818  r->cfGetUnit = nr2mGetUnit;
819  r->cfExtGcd = nr2mExtGcd;
820  r->cfCoeffWrite = nr2mCoeffWrite;
821  r->cfCoeffName = nr2mCoeffName;
822  r->cfQuot1 = nr2mQuot1;
823 #ifdef LDEBUG
824  r->cfDBTest = nr2mDBTest;
825 #endif
826  r->has_simple_Alloc=TRUE;
827  return FALSE;
828 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
static BOOLEAN nr2mGreater(number a, number b, const coeffs r)
Definition: rmodulo2m.cc:448
static char * nr2mCoeffName(const coeffs cf)
Definition: rmodulo2m.cc:51
static number nr2mLcm(number a, number b, const coeffs)
Definition: rmodulo2m.cc:144
static number nr2mAnn(number b, const coeffs r)
Definition: rmodulo2m.cc:557
static BOOLEAN nr2mDivBy(number a, number b, const coeffs r)
Definition: rmodulo2m.cc:420
static void nr2mWrite(number a, const coeffs r)
Definition: rmodulo2m.cc:724
only used if HAVE_RINGS is defined
Definition: coeffs.h:46
#define FALSE
Definition: auxiliary.h:94
return P p
Definition: myNF.cc:203
static long nr2mInt(number &n, const coeffs r)
Definition: rmodulo2m.cc:341
static number nr2mDiv(number a, number b, const coeffs r)
Definition: rmodulo2m.cc:394
#define TRUE
Definition: auxiliary.h:98
static number nr2mGetUnit(number k, const coeffs)
Definition: rmodulo2m.cc:366
static BOOLEAN nr2mIsZero(number a, const coeffs)
Definition: rmodulo2m.cc:374
static BOOLEAN nr2mCoeffIsEqual(const coeffs r, n_coeffType n, void *p)
Definition: rmodulo2m.cc:64
static number nr2mNeg(number c, const coeffs r)
Definition: rmodulo2m.cc:578
static BOOLEAN nr2mIsOne(number a, const coeffs)
Definition: rmodulo2m.cc:379
#define LDEBUG
Definition: mod2.h:312
static const char * nr2mRead(const char *s, number *a, const coeffs r)
Definition: rmodulo2m.cc:749
#define assume(x)
Definition: mod2.h:394
static coeffs nr2mQuot1(number c, const coeffs r)
Definition: rmodulo2m.cc:83
static char * nr2mCoeffString(const coeffs r)
Definition: rmodulo2m.cc:75
static int nr2mDivComp(number as, number bs, const coeffs)
Definition: rmodulo2m.cc:453
static void nr2mInitExp(int m, coeffs r)
Definition: rmodulo2m.cc:708
static BOOLEAN nr2mGreaterZero(number k, const coeffs r)
Definition: rmodulo2m.cc:122
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
static number nr2mMult(number a, number b, const coeffs r)
Definition: rmodulo2m.cc:132
static BOOLEAN nr2mDBTest(number a, const char *, const int, const coeffs r)
Definition: rmodulo2m.cc:716
static number nr2mExtGcd(number a, number b, number *s, number *t, const coeffs r)
Definition: rmodulo2m.cc:280
static BOOLEAN nr2mIsMOne(number a, const coeffs r)
Definition: rmodulo2m.cc:384
static BOOLEAN nr2mEqual(number a, number b, const coeffs)
Definition: rmodulo2m.cc:389
static number nr2mInvers(number c, const coeffs r)
Definition: rmodulo2m.cc:266
static number nr2mSub(number a, number b, const coeffs r)
Definition: rmodulo2m.cc:356
static BOOLEAN nr2mIsUnit(number a, const coeffs)
Definition: rmodulo2m.cc:361
static void nr2mCoeffWrite(const coeffs r, BOOLEAN)
Definition: rmodulo2m.cc:58
static number nr2mInit(long i, const coeffs r)
Definition: rmodulo2m.cc:324
omBin gmp_nrz_bin
Definition: rintegers.cc:76
(int), see modulop.h
Definition: coeffs.h:110
static number nr2mGcd(number a, number b, const coeffs)
Definition: rmodulo2m.cc:167
static number nr2mAdd(number a, number b, const coeffs r)
Definition: rmodulo2m.cc:351
static void nr2mPower(number a, int i, number *result, const coeffs r)
Definition: rmodulo2m.cc:304
static nMapFunc nr2mSetMap(const coeffs src, const coeffs dst)
Definition: rmodulo2m.cc:643
static number nr2mMod(number a, number b, const coeffs r)
Definition: rmodulo2m.cc:480

§ nr2mInitExp()

static void nr2mInitExp ( int  m,
coeffs  r 
)
static

Definition at line 708 of file rmodulo2m.cc.

709 {
710  nr2mSetExp(m, r);
711  if (m < 2)
712  WarnS("nr2mInitExp unexpectedly called with m = 1 (we continue with Z/2^2");
713 }
static void nr2mSetExp(int m, coeffs r)
Definition: rmodulo2m.cc:690
#define WarnS
Definition: emacs.cc:81
int m
Definition: cfEzgcd.cc:119

§ nr2mInt()

static long nr2mInt ( number &  n,
const coeffs  r 
)
static

Definition at line 341 of file rmodulo2m.cc.

342 {
343  unsigned long nn = (unsigned long)(unsigned long)n & r->mod2mMask;
344  unsigned long l = r->mod2mMask >> 1; l++; /* now: l = 2^(m-1) */
345  if ((unsigned long)nn > l)
346  return (long)((unsigned long)nn - r->mod2mMask - 1);
347  else
348  return (long)((unsigned long)nn);
349 }
int l
Definition: cfEzgcd.cc:94

§ nr2mInvers()

static number nr2mInvers ( number  c,
const coeffs  r 
)
static

Definition at line 266 of file rmodulo2m.cc.

267 {
268  if ((unsigned long)c % 2 == 0)
269  {
270  WerrorS("division by zero divisor");
271  return (number)0;
272  }
273  return nr2mInversM(c, r);
274 }
void WerrorS(const char *s)
Definition: feFopen.cc:24
static number nr2mInversM(number c, const coeffs r)
Definition: rmodulo2m.cc:257

§ nr2mInversM()

static number nr2mInversM ( number  c,
const coeffs  r 
)
inlinestatic

Definition at line 257 of file rmodulo2m.cc.

258 {
259  assume((unsigned long)c % 2 != 0);
260  // Table !!!
261  unsigned long inv;
262  inv = InvMod((unsigned long)c,r);
263  return (number)inv;
264 }
static unsigned long InvMod(unsigned long a, const coeffs r)
Definition: rmodulo2m.cc:249
#define assume(x)
Definition: mod2.h:394

§ nr2mIsMOne()

static BOOLEAN nr2mIsMOne ( number  a,
const coeffs  r 
)
static

Definition at line 384 of file rmodulo2m.cc.

385 {
386  return ((r->mod2mMask == (unsigned long)a) &&(1L!=(long)a))/*for char 2^1*/;
387 }
const poly a
Definition: syzextra.cc:212

§ nr2mIsOne()

static BOOLEAN nr2mIsOne ( number  a,
const coeffs   
)
static

Definition at line 379 of file rmodulo2m.cc.

380 {
381  return 1 == (unsigned long)a;
382 }
const poly a
Definition: syzextra.cc:212

§ nr2mIsUnit()

static BOOLEAN nr2mIsUnit ( number  a,
const coeffs   
)
static

Definition at line 361 of file rmodulo2m.cc.

362 {
363  return ((unsigned long)a % 2 == 1);
364 }
const poly a
Definition: syzextra.cc:212

§ nr2mIsZero()

static BOOLEAN nr2mIsZero ( number  a,
const coeffs   
)
static

Definition at line 374 of file rmodulo2m.cc.

375 {
376  return 0 == (unsigned long)a;
377 }
const poly a
Definition: syzextra.cc:212

§ nr2mLcm()

static number nr2mLcm ( number  a,
number  b,
const coeffs   
)
static

Definition at line 144 of file rmodulo2m.cc.

145 {
146  unsigned long res = 0;
147  if ((unsigned long)a == 0) a = (number) 1;
148  if ((unsigned long)b == 0) b = (number) 1;
149  while ((unsigned long)a % 2 == 0)
150  {
151  a = (number)((unsigned long)a / 2);
152  if ((unsigned long)b % 2 == 0) b = (number)((unsigned long)b / 2);
153  res++;
154  }
155  while ((unsigned long)b % 2 == 0)
156  {
157  b = (number)((unsigned long)b / 2);
158  res++;
159  }
160  return (number)(1L << res); // (2**res)
161 }
const poly a
Definition: syzextra.cc:212
poly res
Definition: myNF.cc:322
const poly b
Definition: syzextra.cc:213

§ nr2mMapGMP()

static number nr2mMapGMP ( number  from,
const coeffs  ,
const coeffs  dst 
)
static

Definition at line 607 of file rmodulo2m.cc.

608 {
609  mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
610  mpz_init(erg);
611  mpz_ptr k = (mpz_ptr)omAlloc(sizeof(mpz_t));
612  mpz_init_set_ui(k, dst->mod2mMask);
613 
614  mpz_and(erg, (mpz_ptr)from, k);
615  number res = (number) mpz_get_ui(erg);
616 
617  mpz_clear(erg); omFree((ADDRESS)erg);
618  mpz_clear(k); omFree((ADDRESS)k);
619 
620  return (number)res;
621 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
void * ADDRESS
Definition: auxiliary.h:115
int k
Definition: cfEzgcd.cc:93
#define omAlloc(size)
Definition: omAllocDecl.h:210
poly res
Definition: myNF.cc:322
#define omFree(addr)
Definition: omAllocDecl.h:261
omBin gmp_nrz_bin
Definition: rintegers.cc:76

§ nr2mMapMachineInt()

static number nr2mMapMachineInt ( number  from,
const coeffs  ,
const coeffs  dst 
)
static

Definition at line 584 of file rmodulo2m.cc.

585 {
586  unsigned long i = ((unsigned long)from) % dst->mod2mMask ;
587  return (number)i;
588 }
int i
Definition: cfEzgcd.cc:123

§ nr2mMapProject()

static number nr2mMapProject ( number  from,
const coeffs  ,
const coeffs  dst 
)
static

Definition at line 590 of file rmodulo2m.cc.

591 {
592  unsigned long i = ((unsigned long)from) % (dst->mod2mMask + 1);
593  return (number)i;
594 }
int i
Definition: cfEzgcd.cc:123

§ nr2mMapQ()

static number nr2mMapQ ( number  from,
const coeffs  src,
const coeffs  dst 
)
static

Definition at line 623 of file rmodulo2m.cc.

624 {
625  mpz_ptr gmp = (mpz_ptr)omAllocBin(gmp_nrz_bin);
626  mpz_init(gmp);
627  nlGMP(from, (number)gmp, src); // FIXME? TODO? // extern void nlGMP(number &i, number n, const coeffs r); // to be replaced with n_MPZ(erg, from, src); // ?
628  number res=nr2mMapGMP((number)gmp,src,dst);
629  mpz_clear(gmp); omFree((ADDRESS)gmp);
630  return res;
631 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
static number nr2mMapGMP(number from, const coeffs, const coeffs dst)
Definition: rmodulo2m.cc:607
void * ADDRESS
Definition: auxiliary.h:115
void nlGMP(number &i, number n, const coeffs r)
Definition: longrat.cc:1467
poly res
Definition: myNF.cc:322
#define omFree(addr)
Definition: omAllocDecl.h:261
omBin gmp_nrz_bin
Definition: rintegers.cc:76

§ nr2mMapZ()

static number nr2mMapZ ( number  from,
const coeffs  src,
const coeffs  dst 
)
static

Definition at line 633 of file rmodulo2m.cc.

634 {
635  if (SR_HDL(from) & SR_INT)
636  {
637  long f_i=SR_TO_INT(from);
638  return nr2mInit(f_i,dst);
639  }
640  return nr2mMapGMP(from,src,dst);
641 }
static number nr2mMapGMP(number from, const coeffs, const coeffs dst)
Definition: rmodulo2m.cc:607
#define SR_TO_INT(SR)
Definition: longrat.h:70
#define SR_INT
Definition: longrat.h:68
static number nr2mInit(long i, const coeffs r)
Definition: rmodulo2m.cc:324
#define SR_HDL(A)
Definition: tgb.cc:35

§ nr2mMapZp()

number nr2mMapZp ( number  from,
const coeffs  ,
const coeffs  dst 
)

Definition at line 596 of file rmodulo2m.cc.

597 {
598  unsigned long j = (unsigned long)1;
599  long ii = (long)from;
600  if (ii < 0) { j = dst->mod2mMask; ii = -ii; }
601  unsigned long i = (unsigned long)ii;
602  i = i & dst->mod2mMask;
603  /* now we have: from = j * i mod 2^m */
604  return (number)nr2mMult((number)i, (number)j, dst);
605 }
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
static number nr2mMult(number a, number b, const coeffs r)
Definition: rmodulo2m.cc:132

§ nr2mMod()

static number nr2mMod ( number  a,
number  b,
const coeffs  r 
)
static

Definition at line 480 of file rmodulo2m.cc.

481 {
482  /*
483  We need to return the number rr which is uniquely determined by the
484  following two properties:
485  (1) 0 <= rr < |b| (with respect to '<' and '<=' performed in Z x Z)
486  (2) There exists some k in the integers Z such that a = k * b + rr.
487  Consider g := gcd(2^m, |b|). Note that then |b|/g is a unit in Z/2^m.
488  Now, there are three cases:
489  (a) g = 1
490  Then |b| is a unit in Z/2^m, i.e. |b| (and also b) divides a.
491  Thus rr = 0.
492  (b) g <> 1 and g divides a
493  Then a = (a/g) * (|b|/g)^(-1) * b (up to sign), i.e. again rr = 0.
494  (c) g <> 1 and g does not divide a
495  Let's denote the division with remainder of a by g as follows:
496  a = s * g + t. Then t = a - s * g = a - s * (|b|/g)^(-1) * |b|
497  fulfills (1) and (2), i.e. rr := t is the correct result. Hence
498  in this third case, rr is the remainder of division of a by g in Z.
499  This algorithm is the same as for the case Z/n, except that we may
500  compute the gcd of |b| and 2^m "by hand": We just extract the highest
501  power of 2 (<= 2^m) that is contained in b.
502  */
503  assume((unsigned long) b != 0);
504  unsigned long g = 1;
505  unsigned long b_div = (unsigned long) b;
506 
507  /*
508  * b_div is unsigned, so that (b_div < 0) evaluates false at compile-time
509  *
510  if (b_div < 0) b_div = -b_div; // b_div now represents |b|, BUT b_div is unsigned!
511  */
512 
513  unsigned long rr = 0;
514  while ((g < r->mod2mMask ) && (b_div > 0) && (b_div % 2 == 0))
515  {
516  b_div = b_div >> 1;
517  g = g << 1;
518  } // g is now the gcd of 2^m and |b|
519 
520  if (g != 1) rr = (unsigned long)a % g;
521  return (number)rr;
522 }
const poly a
Definition: syzextra.cc:212
g
Definition: cfModGcd.cc:4031
#define assume(x)
Definition: mod2.h:394
const poly b
Definition: syzextra.cc:213

§ nr2mMult()

static number nr2mMult ( number  a,
number  b,
const coeffs  r 
)
static

Definition at line 132 of file rmodulo2m.cc.

133 {
134  if (((unsigned long)a == 0) || ((unsigned long)b == 0))
135  return (number)0;
136  else
137  return nr2mMultM(a, b, r);
138 }
static number nr2mMultM(number a, number b, const coeffs r)
Definition: rmodulo2m.cc:27
const poly a
Definition: syzextra.cc:212
const poly b
Definition: syzextra.cc:213

§ nr2mMultM()

static number nr2mMultM ( number  a,
number  b,
const coeffs  r 
)
inlinestatic

Definition at line 27 of file rmodulo2m.cc.

28 {
29  return (number)
30  ((((unsigned long) a) * ((unsigned long) b)) & ((unsigned long)r->mod2mMask));
31 }
const poly a
Definition: syzextra.cc:212
const poly b
Definition: syzextra.cc:213

§ nr2mNeg()

static number nr2mNeg ( number  c,
const coeffs  r 
)
static

Definition at line 578 of file rmodulo2m.cc.

579 {
580  if ((unsigned long)c == 0) return c;
581  return nr2mNegM(c, r);
582 }
#define nr2mNegM(A, r)
Definition: rmodulo2m.cc:46

§ nr2mPower()

static void nr2mPower ( number  a,
int  i,
number *  result,
const coeffs  r 
)
static

Definition at line 304 of file rmodulo2m.cc.

305 {
306  if (i == 0)
307  {
308  *(unsigned long *)result = 1;
309  }
310  else if (i == 1)
311  {
312  *result = a;
313  }
314  else
315  {
316  nr2mPower(a, i-1, result, r);
317  *result = nr2mMultM(a, *result, r);
318  }
319 }
static number nr2mMultM(number a, number b, const coeffs r)
Definition: rmodulo2m.cc:27
const poly a
Definition: syzextra.cc:212
int i
Definition: cfEzgcd.cc:123
static void nr2mPower(number a, int i, number *result, const coeffs r)
Definition: rmodulo2m.cc:304
return result
Definition: facAbsBiFact.cc:76

§ nr2mQuot1()

static coeffs nr2mQuot1 ( number  c,
const coeffs  r 
)
static

Definition at line 83 of file rmodulo2m.cc.

84 {
85  coeffs rr;
86  long ch = r->cfInt(c, r);
87  mpz_t a,b;
88  mpz_init_set(a, r->modNumber);
89  mpz_init_set_ui(b, ch);
90  mpz_ptr gcd;
91  gcd = (mpz_ptr) omAlloc(sizeof(mpz_t));
92  mpz_init(gcd);
93  mpz_gcd(gcd, a,b);
94  if(mpz_cmp_ui(gcd, 1) == 0)
95  {
96  WerrorS("constant in q-ideal is coprime to modulus in ground ring");
97  WerrorS("Unable to create qring!");
98  return NULL;
99  }
100  if(mpz_cmp_ui(gcd, 2) == 0)
101  {
102  rr = nInitChar(n_Zp, (void*)2);
103  }
104  else
105  {
106  int kNew = 1;
107  mpz_t baseTokNew;
108  mpz_init(baseTokNew);
109  mpz_set(baseTokNew, r->modBase);
110  while(mpz_cmp(gcd, baseTokNew) > 0)
111  {
112  kNew++;
113  mpz_mul(baseTokNew, baseTokNew, r->modBase);
114  }
115  mpz_clear(baseTokNew);
116  rr = nInitChar(n_Z2m, (void*)(long)kNew);
117  }
118  return(rr);
119 }
const poly a
Definition: syzextra.cc:212
only used if HAVE_RINGS is defined
Definition: coeffs.h:46
{p < 2^31}
Definition: coeffs.h:30
void WerrorS(const char *s)
Definition: feFopen.cc:24
#define omAlloc(size)
Definition: omAllocDecl.h:210
The main handler for Singular numbers which are suitable for Singular polynomials.
#define NULL
Definition: omList.c:10
int gcd(int a, int b)
Definition: walkSupport.cc:839
const poly b
Definition: syzextra.cc:213
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:334

§ nr2mRead()

static const char* nr2mRead ( const char *  s,
number *  a,
const coeffs  r 
)
static

Definition at line 749 of file rmodulo2m.cc.

750 {
751  int z;
752  int n=1;
753 
754  s = nr2mEati(s, &z,r);
755  if ((*s) == '/')
756  {
757  s++;
758  s = nr2mEati(s, &n,r);
759  }
760  if (n == 1)
761  *a = (number)(long)z;
762  else
763  *a = nr2mDiv((number)(long)z,(number)(long)n,r);
764  return s;
765 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
const poly a
Definition: syzextra.cc:212
static number nr2mDiv(number a, number b, const coeffs r)
Definition: rmodulo2m.cc:394
static const char * nr2mEati(const char *s, int *i, const coeffs r)
Definition: rmodulo2m.cc:730

§ nr2mSetExp()

static void nr2mSetExp ( int  m,
coeffs  r 
)
static

Definition at line 690 of file rmodulo2m.cc.

691 {
692  if (m > 1)
693  {
694  /* we want mod2mMask to be the bit pattern
695  '111..1' consisting of m one's: */
696  r->modExponent= m;
697  r->mod2mMask = 1;
698  for (int i = 1; i < m; i++) r->mod2mMask = (r->mod2mMask << 1) + 1;
699  }
700  else
701  {
702  r->modExponent= 2;
703  /* code unexpectedly called with m = 1; we continue with m = 2: */
704  r->mod2mMask = 3; /* i.e., '11' in binary representation */
705  }
706 }
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123

§ nr2mSetMap()

static nMapFunc nr2mSetMap ( const coeffs  src,
const coeffs  dst 
)
static

Definition at line 643 of file rmodulo2m.cc.

644 {
645  if ((src->rep==n_rep_int) && nCoeff_is_Ring_2toM(src)
646  && (src->mod2mMask == dst->mod2mMask))
647  {
648  return ndCopyMap;
649  }
650  if ((src->rep==n_rep_int) && nCoeff_is_Ring_2toM(src)
651  && (src->mod2mMask < dst->mod2mMask))
652  { /* i.e. map an integer mod 2^s into Z mod 2^t, where t < s */
653  return nr2mMapMachineInt;
654  }
655  if ((src->rep==n_rep_int) && nCoeff_is_Ring_2toM(src)
656  && (src->mod2mMask > dst->mod2mMask))
657  { /* i.e. map an integer mod 2^s into Z mod 2^t, where t > s */
658  // to be done
659  return nr2mMapProject;
660  }
661  if ((src->rep==n_rep_gmp) && nCoeff_is_Ring_Z(src))
662  {
663  return nr2mMapGMP;
664  }
665  if ((src->rep==n_rep_gap_gmp) /*&& nCoeff_is_Ring_Z(src)*/)
666  {
667  return nr2mMapZ;
668  }
669  if ((src->rep==n_rep_gap_rat) && (nCoeff_is_Q(src)||nCoeff_is_Ring_Z(src)))
670  {
671  return nr2mMapQ;
672  }
673  if ((src->rep==n_rep_int) && nCoeff_is_Zp(src) && (src->ch == 2))
674  {
675  return nr2mMapZp;
676  }
677  if ((src->rep==n_rep_gmp) &&
679  {
680  if (mpz_divisible_2exp_p(src->modNumber,dst->modExponent))
681  return nr2mMapGMP;
682  }
683  return NULL; // default
684 }
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_ModN(const coeffs r)
Definition: coeffs.h:753
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:834
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
Definition: numbers.cc:244
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_Z(const coeffs r)
Definition: coeffs.h:759
static number nr2mMapGMP(number from, const coeffs, const coeffs dst)
Definition: rmodulo2m.cc:607
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_2toM(const coeffs r)
Definition: coeffs.h:750
(), see rinteger.h, new impl.
Definition: coeffs.h:112
number nr2mMapZp(number from, const coeffs, const coeffs dst)
Definition: rmodulo2m.cc:596
static number nr2mMapMachineInt(number from, const coeffs, const coeffs dst)
Definition: rmodulo2m.cc:584
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:840
static number nr2mMapProject(number from, const coeffs, const coeffs dst)
Definition: rmodulo2m.cc:590
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_PtoM(const coeffs r)
Definition: coeffs.h:756
(mpz_ptr), see rmodulon,h
Definition: coeffs.h:115
(number), see longrat.h
Definition: coeffs.h:111
#define NULL
Definition: omList.c:10
static number nr2mMapQ(number from, const coeffs src, const coeffs dst)
Definition: rmodulo2m.cc:623
(int), see modulop.h
Definition: coeffs.h:110
static number nr2mMapZ(number from, const coeffs src, const coeffs dst)
Definition: rmodulo2m.cc:633

§ nr2mSub()

static number nr2mSub ( number  a,
number  b,
const coeffs  r 
)
static

Definition at line 356 of file rmodulo2m.cc.

357 {
358  return nr2mSubM(a, b, r);
359 }
const poly a
Definition: syzextra.cc:212
static number nr2mSubM(number a, number b, const coeffs r)
Definition: rmodulo2m.cc:39
const poly b
Definition: syzextra.cc:213

§ nr2mSubM()

static number nr2mSubM ( number  a,
number  b,
const coeffs  r 
)
inlinestatic

Definition at line 39 of file rmodulo2m.cc.

40 {
41  return (number)((unsigned long)a < (unsigned long)b ?
42  r->mod2mMask - (unsigned long)b + (unsigned long)a + 1:
43  (unsigned long)a - (unsigned long)b);
44 }
const poly a
Definition: syzextra.cc:212
const poly b
Definition: syzextra.cc:213

§ nr2mWrite()

static void nr2mWrite ( number  a,
const coeffs  r 
)
static

Definition at line 724 of file rmodulo2m.cc.

725 {
726  long i = nr2mInt(a, r);
727  StringAppend("%ld", i);
728 }
const poly a
Definition: syzextra.cc:212
static long nr2mInt(number &n, const coeffs r)
Definition: rmodulo2m.cc:341
#define StringAppend
Definition: emacs.cc:82
int i
Definition: cfEzgcd.cc:123

§ specialXGCD()

static void specialXGCD ( unsigned long &  s,
unsigned long  a,
const coeffs  r 
)
static

Definition at line 191 of file rmodulo2m.cc.

192 {
193  mpz_ptr u = (mpz_ptr)omAlloc(sizeof(mpz_t));
194  mpz_init_set_ui(u, a);
195  mpz_ptr u0 = (mpz_ptr)omAlloc(sizeof(mpz_t));
196  mpz_init(u0);
197  mpz_ptr u1 = (mpz_ptr)omAlloc(sizeof(mpz_t));
198  mpz_init_set_ui(u1, 1);
199  mpz_ptr u2 = (mpz_ptr)omAlloc(sizeof(mpz_t));
200  mpz_init(u2);
201  mpz_ptr v = (mpz_ptr)omAlloc(sizeof(mpz_t));
202  mpz_init_set_ui(v, r->mod2mMask);
203  mpz_add_ui(v, v, 1); /* now: v = 2^m */
204  mpz_ptr v0 = (mpz_ptr)omAlloc(sizeof(mpz_t));
205  mpz_init(v0);
206  mpz_ptr v1 = (mpz_ptr)omAlloc(sizeof(mpz_t));
207  mpz_init(v1);
208  mpz_ptr v2 = (mpz_ptr)omAlloc(sizeof(mpz_t));
209  mpz_init_set_ui(v2, 1);
210  mpz_ptr q = (mpz_ptr)omAlloc(sizeof(mpz_t));
211  mpz_init(q);
212  mpz_ptr rr = (mpz_ptr)omAlloc(sizeof(mpz_t));
213  mpz_init(rr);
214 
215  while (mpz_cmp_ui(v, 0) != 0) /* i.e., while v != 0 */
216  {
217  mpz_div(q, u, v);
218  mpz_mod(rr, u, v);
219  mpz_set(u, v);
220  mpz_set(v, rr);
221  mpz_set(u0, u2);
222  mpz_set(v0, v2);
223  mpz_mul(u2, u2, q); mpz_sub(u2, u1, u2); /* u2 = u1 - q * u2 */
224  mpz_mul(v2, v2, q); mpz_sub(v2, v1, v2); /* v2 = v1 - q * v2 */
225  mpz_set(u1, u0);
226  mpz_set(v1, v0);
227  }
228 
229  while (mpz_cmp_ui(u1, 0) < 0) /* i.e., while u1 < 0 */
230  {
231  /* we add 2^m = (2^m - 1) + 1 to u1: */
232  mpz_add_ui(u1, u1, r->mod2mMask);
233  mpz_add_ui(u1, u1, 1);
234  }
235  s = mpz_get_ui(u1); /* now: 0 <= s <= 2^m - 1 */
236 
237  mpz_clear(u); omFree((ADDRESS)u);
238  mpz_clear(u0); omFree((ADDRESS)u0);
239  mpz_clear(u1); omFree((ADDRESS)u1);
240  mpz_clear(u2); omFree((ADDRESS)u2);
241  mpz_clear(v); omFree((ADDRESS)v);
242  mpz_clear(v0); omFree((ADDRESS)v0);
243  mpz_clear(v1); omFree((ADDRESS)v1);
244  mpz_clear(v2); omFree((ADDRESS)v2);
245  mpz_clear(q); omFree((ADDRESS)q);
246  mpz_clear(rr); omFree((ADDRESS)rr);
247 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
const poly a
Definition: syzextra.cc:212
void * ADDRESS
Definition: auxiliary.h:115
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define omFree(addr)
Definition: omAllocDecl.h:261
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37

Variable Documentation

§ gmp_nrz_bin

omBin gmp_nrz_bin

Definition at line 76 of file rintegers.cc.