Data Structures | Macros | Functions
longrat.h File Reference
#include <misc/auxiliary.h>
#include <coeffs/si_gmp.h>
#include <coeffs/coeffs.h>

Go to the source code of this file.

Data Structures

struct  number
 'SR_INT' is the type of those integers small enough to fit into 29 bits. More...
 

Macros

#define SR_HDL(A)   ((long)(A))
 
#define SR_INT   1L
 
#define INT_TO_SR(INT)   ((number) (((long)INT << 2) + SR_INT))
 
#define SR_TO_INT(SR)   (((long)SR) >> 2)
 
#define MP_SMALL   1
 

Functions

number nlGetDenom (number &n, const coeffs r)
 
number nlGetNumerator (number &n, const coeffs r)
 
BOOLEAN nlInitChar (coeffs, void *)
 
static FORCE_INLINE int nlQlogSize (number n, const coeffs r)
 only used by slimgb (tgb.cc) More...
 
static FORCE_INLINE BOOLEAN nlIsInteger (number q, const coeffs r)
 
number nlModP (number q, const coeffs Q, const coeffs Zp)
 
void nlNormalize (number &x, const coeffs r)
 
void nlInpGcd (number &a, number b, const coeffs r)
 
void nlDelete (number *a, const coeffs r)
 
number nlInit2 (int i, int j, const coeffs r)
 create a rational i/j (implicitly) over Q NOTE: make sure to use correct Q in debug mode More...
 
number nlInit2gmp (mpz_t i, mpz_t j, const coeffs r)
 create a rational i/j (implicitly) over Q NOTE: make sure to use correct Q in debug mode More...
 
void nlGMP (number &i, number n, const coeffs r)
 
number nlMapGMP (number from, const coeffs src, const coeffs dst)
 

Data Structure Documentation

§ snumber

struct snumber

'SR_INT' is the type of those integers small enough to fit into 29 bits.

Therefor the value range of this small integers is: $-2^{28}...2^{28}-1$.

Small integers are represented by an immediate integer handle, containing the value instead of pointing to it, which has the following form:

+-------+-------+-------+-------+- - - -+-------+-------+-------+
| guard | sign  | bit   | bit   |       | bit   | tag   | tag   |
| bit   | bit   | 27    | 26    |       | 0     | 0     | 1     |
+-------+-------+-------+-------+- - - -+-------+-------+-------+

Immediate integers handles carry the tag 'SR_INT', i.e. the last bit is 1. This distuingishes immediate integers from other handles which point to structures aligned on 4 byte boundaries and therefor have last bit zero. (The second bit is reserved as tag to allow extensions of this scheme.) Using immediates as pointers and dereferencing them gives address errors.

To aid overflow check the most significant two bits must always be equal, that is to say that the sign bit of immediate integers has a guard bit.

The macros 'INT_TO_SR' and 'SR_TO_INT' should be used to convert between a small integer value and its representation as immediate integer handle.

Large integers and rationals are represented by z and n where n may be undefined (if s==3) NULL represents only deleted values

Definition at line 49 of file longrat.h.

Data Fields
int debug
mpz_t n
BOOLEAN s parameter s in number: 0 (or FALSE): not normalised rational 1 (or TRUE): normalised rational 3 : integer with n==NULL
mpz_t z

Macro Definition Documentation

§ INT_TO_SR

#define INT_TO_SR (   INT)    ((number) (((long)INT << 2) + SR_INT))

Definition at line 69 of file longrat.h.

§ MP_SMALL

#define MP_SMALL   1

Definition at line 72 of file longrat.h.

§ SR_HDL

#define SR_HDL (   A)    ((long)(A))

Definition at line 66 of file longrat.h.

§ SR_INT

#define SR_INT   1L

Definition at line 68 of file longrat.h.

§ SR_TO_INT

#define SR_TO_INT (   SR)    (((long)SR) >> 2)

Definition at line 70 of file longrat.h.

Function Documentation

§ nlDelete()

void nlDelete ( number *  a,
const coeffs  r 
)

Definition at line 2478 of file longrat.cc.

2479 {
2480  if (*a!=NULL)
2481  {
2482  nlTest(*a, r);
2483  if ((SR_HDL(*a) & SR_INT)==0)
2484  {
2485  _nlDelete_NoImm(a);
2486  }
2487  *a=NULL;
2488  }
2489 }
const poly a
Definition: syzextra.cc:212
void _nlDelete_NoImm(number *a)
Definition: longrat.cc:1614
#define NULL
Definition: omList.c:10
#define SR_INT
Definition: longrat.h:68
#define SR_HDL(A)
Definition: tgb.cc:35
#define nlTest(a, r)
Definition: longrat.cc:88

§ nlGetDenom()

number nlGetDenom ( number &  n,
const coeffs  r 
)

Definition at line 1486 of file longrat.cc.

1487 {
1488  if (!(SR_HDL(n) & SR_INT))
1489  {
1490  if (n->s==0)
1491  {
1492  nlNormalize(n,r);
1493  }
1494  if (!(SR_HDL(n) & SR_INT))
1495  {
1496  if (n->s!=3)
1497  {
1498  number u=ALLOC_RNUMBER();
1499  u->s=3;
1500 #if defined(LDEBUG)
1501  u->debug=123456;
1502 #endif
1503  mpz_init_set(u->z,n->n);
1504  u=nlShort3_noinline(u);
1505  return u;
1506  }
1507  }
1508  }
1509  return INT_TO_SR(1);
1510 }
#define INT_TO_SR(INT)
Definition: longrat.h:69
number nlShort3_noinline(number x)
Definition: longrat.cc:170
void nlNormalize(number &x, const coeffs r)
Definition: longrat.cc:1332
#define SR_INT
Definition: longrat.h:68
#define ALLOC_RNUMBER()
Definition: coeffs.h:87
#define SR_HDL(A)
Definition: tgb.cc:35

§ nlGetNumerator()

number nlGetNumerator ( number &  n,
const coeffs  r 
)

Definition at line 1515 of file longrat.cc.

1516 {
1517  if (!(SR_HDL(n) & SR_INT))
1518  {
1519  if (n->s==0)
1520  {
1521  nlNormalize(n,r);
1522  }
1523  if (!(SR_HDL(n) & SR_INT))
1524  {
1525  number u=ALLOC_RNUMBER();
1526 #if defined(LDEBUG)
1527  u->debug=123456;
1528 #endif
1529  u->s=3;
1530  mpz_init_set(u->z,n->z);
1531  if (n->s!=3)
1532  {
1533  u=nlShort3_noinline(u);
1534  }
1535  return u;
1536  }
1537  }
1538  return n; // imm. int
1539 }
number nlShort3_noinline(number x)
Definition: longrat.cc:170
void nlNormalize(number &x, const coeffs r)
Definition: longrat.cc:1332
#define SR_INT
Definition: longrat.h:68
#define ALLOC_RNUMBER()
Definition: coeffs.h:87
#define SR_HDL(A)
Definition: tgb.cc:35

§ nlGMP()

void nlGMP ( number &  i,
number  n,
const coeffs  r 
)

Definition at line 1465 of file longrat.cc.

1466 {
1467  // Hier brauche ich einfach die GMP Zahl
1468  nlTest(i, r);
1469  nlNormalize(i, r);
1470  if (SR_HDL(i) & SR_INT)
1471  {
1472  mpz_set_si((mpz_ptr) n, SR_TO_INT(i));
1473  return;
1474  }
1475  if (i->s!=3)
1476  {
1477  WarnS("Omitted denominator during coefficient mapping !");
1478  }
1479  mpz_set((mpz_ptr) n, i->z);
1480 }
#define WarnS
Definition: emacs.cc:81
int i
Definition: cfEzgcd.cc:123
#define SR_TO_INT(SR)
Definition: longrat.h:70
void nlNormalize(number &x, const coeffs r)
Definition: longrat.cc:1332
#define SR_INT
Definition: longrat.h:68
#define SR_HDL(A)
Definition: tgb.cc:35
#define nlTest(a, r)
Definition: longrat.cc:88

§ nlInit2()

number nlInit2 ( int  i,
int  j,
const coeffs  r 
)

create a rational i/j (implicitly) over Q NOTE: make sure to use correct Q in debug mode

Definition at line 2356 of file longrat.cc.

2357 {
2358  number z=ALLOC_RNUMBER();
2359 #if defined(LDEBUG)
2360  z->debug=123456;
2361 #endif
2362  mpz_init_set_si(z->z,(long)i);
2363  mpz_init_set_si(z->n,(long)j);
2364  z->s = 0;
2365  nlNormalize(z,r);
2366  return z;
2367 }
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
void nlNormalize(number &x, const coeffs r)
Definition: longrat.cc:1332
#define ALLOC_RNUMBER()
Definition: coeffs.h:87

§ nlInit2gmp()

number nlInit2gmp ( mpz_t  i,
mpz_t  j,
const coeffs  r 
)

create a rational i/j (implicitly) over Q NOTE: make sure to use correct Q in debug mode

Definition at line 2369 of file longrat.cc.

2370 {
2371  number z=ALLOC_RNUMBER();
2372 #if defined(LDEBUG)
2373  z->debug=123456;
2374 #endif
2375  mpz_init_set(z->z,i);
2376  mpz_init_set(z->n,j);
2377  z->s = 0;
2378  nlNormalize(z,r);
2379  return z;
2380 }
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
void nlNormalize(number &x, const coeffs r)
Definition: longrat.cc:1332
#define ALLOC_RNUMBER()
Definition: coeffs.h:87

§ nlInitChar()

BOOLEAN nlInitChar ( coeffs  ,
void *   
)

Definition at line 3304 of file longrat.cc.

3305 {
3306  r->is_domain=TRUE;
3307  r->rep=n_rep_gap_rat;
3308 
3309  //const int ch = (int)(long)(p);
3310 
3311  r->nCoeffIsEqual=nlCoeffIsEqual;
3312  //r->cfKillChar = ndKillChar; /* dummy */
3313  r->cfCoeffString=nlCoeffString;
3314  r->cfCoeffName=nlCoeffName;
3315 
3316  r->cfInitMPZ = nlInitMPZ;
3317  r->cfMPZ = nlMPZ;
3318 
3319  r->cfMult = nlMult;
3320  r->cfSub = nlSub;
3321  r->cfAdd = nlAdd;
3322  if (p==NULL) /* Q */
3323  {
3324  r->is_field=TRUE;
3325  r->cfDiv = nlDiv;
3326  //r->cfGcd = ndGcd_dummy;
3327  r->cfSubringGcd = nlGcd;
3328  }
3329  else /* Z: coeffs_BIGINT */
3330  {
3331  r->is_field=FALSE;
3332  r->cfDiv = nlIntDiv;
3333  r->cfIntMod= nlIntMod;
3334  r->cfGcd = nlGcd;
3335  r->cfDivBy=nlDivBy;
3336  r->cfDivComp = nlDivComp;
3337  r->cfIsUnit = nlIsUnit;
3338  r->cfGetUnit = nlGetUnit;
3339  r->cfQuot1 = nlQuot1;
3340  r->cfLcm = nlLcm;
3341  r->cfXExtGcd=nlXExtGcd;
3342  r->cfQuotRem=nlQuotRem;
3343  }
3344  r->cfExactDiv= nlExactDiv;
3345  r->cfInit = nlInit;
3346  r->cfSize = nlSize;
3347  r->cfInt = nlInt;
3348 
3349  r->cfChineseRemainder=nlChineseRemainderSym;
3350  r->cfFarey=nlFarey;
3351  r->cfInpNeg = nlNeg;
3352  r->cfInvers= nlInvers;
3353  r->cfCopy = nlCopy;
3354  r->cfRePart = nlCopy;
3355  //r->cfImPart = ndReturn0;
3356  r->cfWriteLong = nlWrite;
3357  r->cfRead = nlRead;
3358  r->cfNormalize=nlNormalize;
3359  r->cfGreater = nlGreater;
3360  r->cfEqual = nlEqual;
3361  r->cfIsZero = nlIsZero;
3362  r->cfIsOne = nlIsOne;
3363  r->cfIsMOne = nlIsMOne;
3364  r->cfGreaterZero = nlGreaterZero;
3365  r->cfPower = nlPower;
3366  r->cfGetDenom = nlGetDenom;
3367  r->cfGetNumerator = nlGetNumerator;
3368  r->cfExtGcd = nlExtGcd; // only for ring stuff and Z
3369  r->cfNormalizeHelper = nlNormalizeHelper;
3370  r->cfDelete= nlDelete;
3371  r->cfSetMap = nlSetMap;
3372  //r->cfName = ndName;
3373  r->cfInpMult=nlInpMult;
3374  r->cfInpAdd=nlInpAdd;
3375  r->cfCoeffWrite=nlCoeffWrite;
3376 
3377  r->cfClearContent = nlClearContent;
3378  r->cfClearDenominators = nlClearDenominators;
3379 
3380 #ifdef LDEBUG
3381  // debug stuff
3382  r->cfDBTest=nlDBTest;
3383 #endif
3384  r->convSingNFactoryN=nlConvSingNFactoryN;
3385  r->convFactoryNSingN=nlConvFactoryNSingN;
3386 
3387  r->cfRandom=nlRandom;
3388 
3389  // io via ssi
3390  r->cfWriteFd=nlWriteFd;
3391  r->cfReadFd=nlReadFd;
3392 
3393  // the variables: general stuff (required)
3394  r->nNULL = INT_TO_SR(0);
3395  //r->type = n_Q;
3396  r->ch = 0;
3397  r->has_simple_Alloc=FALSE;
3398  r->has_simple_Inverse=FALSE;
3399 
3400  // variables for this type of coeffs:
3401  // (none)
3402  return FALSE;
3403 }
number nlGetUnit(number n, const coeffs r)
Definition: longrat.cc:951
LINLINE number nlSub(number la, number li, const coeffs r)
Definition: longrat.cc:2579
static void nlClearDenominators(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
Definition: longrat.cc:3048
#define INT_TO_SR(INT)
Definition: longrat.h:69
BOOLEAN nlCoeffIsEqual(const coeffs r, n_coeffType n, void *p)
Definition: longrat.cc:3268
char * nlCoeffName(const coeffs r)
Definition: longrat.cc:3142
static number nlConvFactoryNSingN(const CanonicalForm f, const coeffs r)
Definition: longrat.cc:376
BOOLEAN nlGreaterZero(number za, const coeffs r)
Definition: longrat.cc:1153
#define FALSE
Definition: auxiliary.h:97
static void nlMPZ(mpz_t m, number &n, const coeffs r)
Definition: longrat.cc:2631
return P p
Definition: myNF.cc:203
number nlNormalizeHelper(number a, number b, const coeffs r)
Definition: longrat.cc:1376
LINLINE void nlInpAdd(number &a, number b, const coeffs r)
Definition: longrat.cc:2531
number nlGetDenom(number &n, const coeffs r)
Definition: longrat.cc:1486
void nlWrite(number a, const coeffs r)
Definition: longrat0.cc:116
int nlSize(number a, const coeffs)
Definition: longrat.cc:574
LINLINE number nlAdd(number la, number li, const coeffs r)
Definition: longrat.cc:2513
BOOLEAN nlIsMOne(number a, const coeffs r)
Definition: longrat.cc:1178
void nlCoeffWrite(const coeffs r, BOOLEAN details)
Definition: longrat.cc:2908
number nlIntDiv(number a, number b, const coeffs r)
Definition: longrat.cc:784
number nlGcd(number a, number b, const coeffs r)
Definition: longrat.cc:1190
#define TRUE
Definition: auxiliary.h:101
coeffs nlQuot1(number c, const coeffs r)
Definition: longrat.cc:956
const char * nlRead(const char *s, number *a, const coeffs r)
Definition: longrat0.cc:57
number nlIntMod(number a, number b, const coeffs r)
Definition: longrat.cc:865
BOOLEAN nlGreater(number a, number b, const coeffs r)
Definition: longrat.cc:1163
static number nlInitMPZ(mpz_t m, const coeffs)
Definition: longrat.cc:2640
LINLINE BOOLEAN nlIsOne(number a, const coeffs r)
Definition: longrat.cc:2436
static number nlLcm(number a, number b, const coeffs r)
Definition: longrat.cc:3280
const ring r
Definition: syzextra.cc:208
LINLINE number nlNeg(number za, const coeffs r)
Definition: longrat.cc:2494
number nlXExtGcd(number a, number b, number *s, number *t, number *u, number *v, const coeffs r)
Definition: longrat.cc:2652
number nlDiv(number a, number b, const coeffs r)
Definition: longrat.cc:990
LINLINE number nlMult(number a, number b, const coeffs r)
Definition: longrat.cc:2549
number nlInvers(number a, const coeffs r)
Definition: longrat.cc:653
int nlDivComp(number a, number b, const coeffs r)
Definition: longrat.cc:940
LINLINE void nlInpMult(number &a, number b, const coeffs r)
Definition: longrat.cc:2597
static void nlWriteFd(number n, FILE *f, const coeffs)
Definition: longrat.cc:3160
LINLINE BOOLEAN nlEqual(number a, number b, const coeffs r)
Definition: longrat.cc:2409
void nlPower(number x, int exp, number *lu, const coeffs r)
Definition: longrat.cc:1100
number nlQuotRem(number a, number b, number *r, const coeffs R)
Definition: longrat.cc:2704
static number nlReadFd(s_buff f, const coeffs)
Definition: longrat.cc:3206
number nlExtGcd(number a, number b, number *s, number *t, const coeffs)
Definition: longrat.cc:2859
LINLINE BOOLEAN nlIsZero(number za, const coeffs r)
Definition: longrat.cc:2445
static void nlClearContent(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
Definition: longrat.cc:2957
static CanonicalForm nlConvSingNFactoryN(number n, const BOOLEAN setChar, const coeffs)
Definition: longrat.cc:338
(number), see longrat.h
Definition: coeffs.h:111
void nlNormalize(number &x, const coeffs r)
Definition: longrat.cc:1332
number nlChineseRemainderSym(number *x, number *q, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs CF)
Definition: longrat.cc:2917
#define NULL
Definition: omList.c:10
static number nlRandom(siRandProc p, number v2, number, const coeffs cf)
Definition: longrat.cc:3290
LINLINE void nlDelete(number *a, const coeffs r)
Definition: longrat.cc:2478
BOOLEAN nlDivBy(number a, number b, const coeffs)
Definition: longrat.cc:926
BOOLEAN nlIsUnit(number a, const coeffs)
Definition: longrat.cc:981
long nlInt(number &n, const coeffs r)
Definition: longrat.cc:603
nMapFunc nlSetMap(const coeffs src, const coeffs dst)
Definition: longrat.cc:2305
number nlExactDiv(number a, number b, const coeffs r)
Definition: longrat.cc:733
BOOLEAN nlDBTest(number a, const char *f, const int l)
LINLINE number nlInit(long i, const coeffs r)
Definition: longrat.cc:2418
static char * nlCoeffString(const coeffs r)
Definition: longrat.cc:3148
number nlGetNumerator(number &n, const coeffs r)
Definition: longrat.cc:1515
LINLINE number nlCopy(number a, const coeffs r)
Definition: longrat.cc:2465
number nlFarey(number nN, number nP, const coeffs CF)
Definition: longrat.cc:2790

§ nlInpGcd()

void nlInpGcd ( number &  a,
number  b,
const coeffs  r 
)

Definition at line 2757 of file longrat.cc.

2758 {
2759  if ((SR_HDL(b)|SR_HDL(a))&SR_INT)
2760  {
2761  number n=nlGcd(a,b,r);
2762  nlDelete(&a,r);
2763  a=n;
2764  }
2765  else
2766  {
2767  mpz_gcd(a->z,a->z,b->z);
2769  }
2770 }
const poly a
Definition: syzextra.cc:212
number nlGcd(number a, number b, const coeffs r)
Definition: longrat.cc:1190
number nlShort3_noinline(number x)
Definition: longrat.cc:170
LINLINE void nlDelete(number *a, const coeffs r)
Definition: longrat.cc:2478
#define SR_INT
Definition: longrat.h:68
#define SR_HDL(A)
Definition: tgb.cc:35
const poly b
Definition: syzextra.cc:213

§ nlIsInteger()

static FORCE_INLINE BOOLEAN nlIsInteger ( number  q,
const coeffs  r 
)
static

Definition at line 102 of file longrat.h.

103 {
104  assume( nCoeff_is_Q (r) );
105  n_Test(q, r);
106 
107  if (SR_HDL(q) & SR_INT)
108  return TRUE; // immediate int
109 
110  return ( q->s == 3 );
111 }
#define SR_HDL(A)
Definition: longrat.h:66
#define TRUE
Definition: auxiliary.h:101
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:840
#define assume(x)
Definition: mod2.h:403
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:742
#define SR_INT
Definition: longrat.h:68

§ nlMapGMP()

number nlMapGMP ( number  from,
const coeffs  src,
const coeffs  dst 
)

Definition at line 206 of file longrat.cc.

207 {
208  number z=ALLOC_RNUMBER();
209 #if defined(LDEBUG)
210  z->debug=123456;
211 #endif
212  mpz_init_set(z->z,(mpz_ptr) from);
213  //mpz_init_set_ui(&z->n,1);
214  z->s = 3;
215  z=nlShort3(z);
216  return z;
217 }
static number nlShort3(number x)
Definition: longrat.cc:110
#define ALLOC_RNUMBER()
Definition: coeffs.h:87

§ nlModP()

number nlModP ( number  q,
const coeffs  Q,
const coeffs  Zp 
)

Definition at line 1423 of file longrat.cc.

1424 {
1425  const int p = n_GetChar(Zp);
1426  assume( p > 0 );
1427 
1428  const long P = p;
1429  assume( P > 0 );
1430 
1431  // embedded long within q => only long numerator has to be converted
1432  // to int (modulo char.)
1433  if (SR_HDL(q) & SR_INT)
1434  {
1435  long i = SR_TO_INT(q);
1436  return n_Init( i, Zp );
1437  }
1438 
1439  const unsigned long PP = p;
1440 
1441  // numerator modulo char. should fit into int
1442  number z = n_Init( static_cast<long>(mpz_fdiv_ui(q->z, PP)), Zp );
1443 
1444  // denominator != 1?
1445  if (q->s!=3)
1446  {
1447  // denominator modulo char. should fit into int
1448  number n = n_Init( static_cast<long>(mpz_fdiv_ui(q->n, PP)), Zp );
1449 
1450  number res = n_Div( z, n, Zp );
1451 
1452  n_Delete(&z, Zp);
1453  n_Delete(&n, Zp);
1454 
1455  return res;
1456  }
1457 
1458  return z;
1459 }
return P p
Definition: myNF.cc:203
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:542
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:448
poly res
Definition: myNF.cc:322
#define assume(x)
Definition: mod2.h:403
int i
Definition: cfEzgcd.cc:123
#define SR_TO_INT(SR)
Definition: longrat.h:70
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of &#39;a&#39; and &#39;b&#39;, i.e., a/b; raises an error if &#39;b&#39; is not invertible in r exceptio...
Definition: coeffs.h:619
#define SR_INT
Definition: longrat.h:68
#define SR_HDL(A)
Definition: tgb.cc:35
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
kBucketDestroy & P
Definition: myNF.cc:191

§ nlNormalize()

void nlNormalize ( number &  x,
const coeffs  r 
)

Definition at line 1332 of file longrat.cc.

1333 {
1334  if ((SR_HDL(x) & SR_INT) ||(x==NULL))
1335  return;
1336  if (x->s==3)
1337  {
1339  nlTest(x,r);
1340  return;
1341  }
1342  else if (x->s==0)
1343  {
1344  if (mpz_cmp_si(x->n,1L)==0)
1345  {
1346  mpz_clear(x->n);
1347  x->s=3;
1348  x=nlShort3(x);
1349  }
1350  else
1351  {
1352  mpz_t gcd;
1353  mpz_init(gcd);
1354  mpz_gcd(gcd,x->z,x->n);
1355  x->s=1;
1356  if (mpz_cmp_si(gcd,1L)!=0)
1357  {
1358  mpz_divexact(x->z,x->z,gcd);
1359  mpz_divexact(x->n,x->n,gcd);
1360  if (mpz_cmp_si(x->n,1L)==0)
1361  {
1362  mpz_clear(x->n);
1363  x->s=3;
1365  }
1366  }
1367  mpz_clear(gcd);
1368  }
1369  }
1370  nlTest(x, r);
1371 }
number nlShort3_noinline(number x)
Definition: longrat.cc:170
#define NULL
Definition: omList.c:10
static number nlShort3(number x)
Definition: longrat.cc:110
int gcd(int a, int b)
Definition: walkSupport.cc:839
#define SR_INT
Definition: longrat.h:68
Variable x
Definition: cfModGcd.cc:4023
#define SR_HDL(A)
Definition: tgb.cc:35
#define nlTest(a, r)
Definition: longrat.cc:88

§ nlQlogSize()

static FORCE_INLINE int nlQlogSize ( number  n,
const coeffs  r 
)
static

only used by slimgb (tgb.cc)

Definition at line 77 of file longrat.h.

78 {
79  assume( nCoeff_is_Q (r) );
80 
81  long nl=n_Size(n,r);
82  if (nl==0L) return 0;
83  if (nl==1L)
84  {
85  long i = SR_TO_INT (n);
86  unsigned long v;
87  v = (i >= 0) ? i : -i;
88  int r = 0;
89 
90  while(v >>= 1)
91  {
92  r++;
93  }
94  return r + 1;
95  }
96  //assume denominator is 0
97  number nn=(number) n;
98  return mpz_sizeinbase (nn->z, 2);
99 }
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:840
#define assume(x)
Definition: mod2.h:403
int i
Definition: cfEzgcd.cc:123
#define SR_TO_INT(SR)
Definition: longrat.h:70
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
static FORCE_INLINE int n_Size(number n, const coeffs r)
return a non-negative measure for the complexity of n; return 0 only when n represents zero; (used fo...
Definition: coeffs.h:574