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 2484 of file longrat.cc.

2485 {
2486  if (*a!=NULL)
2487  {
2488  nlTest(*a, r);
2489  if ((SR_HDL(*a) & SR_INT)==0)
2490  {
2491  _nlDelete_NoImm(a);
2492  }
2493  *a=NULL;
2494  }
2495 }
const poly a
Definition: syzextra.cc:212
void _nlDelete_NoImm(number *a)
Definition: longrat.cc:1616
#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 1488 of file longrat.cc.

1489 {
1490  if (!(SR_HDL(n) & SR_INT))
1491  {
1492  if (n->s==0)
1493  {
1494  nlNormalize(n,r);
1495  }
1496  if (!(SR_HDL(n) & SR_INT))
1497  {
1498  if (n->s!=3)
1499  {
1500  number u=ALLOC_RNUMBER();
1501  u->s=3;
1502 #if defined(LDEBUG)
1503  u->debug=123456;
1504 #endif
1505  mpz_init_set(u->z,n->n);
1506  u=nlShort3_noinline(u);
1507  return u;
1508  }
1509  }
1510  }
1511  return INT_TO_SR(1);
1512 }
#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:1334
#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 1517 of file longrat.cc.

1518 {
1519  if (!(SR_HDL(n) & SR_INT))
1520  {
1521  if (n->s==0)
1522  {
1523  nlNormalize(n,r);
1524  }
1525  if (!(SR_HDL(n) & SR_INT))
1526  {
1527  number u=ALLOC_RNUMBER();
1528 #if defined(LDEBUG)
1529  u->debug=123456;
1530 #endif
1531  u->s=3;
1532  mpz_init_set(u->z,n->z);
1533  if (n->s!=3)
1534  {
1535  u=nlShort3_noinline(u);
1536  }
1537  return u;
1538  }
1539  }
1540  return n; // imm. int
1541 }
number nlShort3_noinline(number x)
Definition: longrat.cc:170
void nlNormalize(number &x, const coeffs r)
Definition: longrat.cc:1334
#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 1467 of file longrat.cc.

1468 {
1469  // Hier brauche ich einfach die GMP Zahl
1470  nlTest(i, r);
1471  nlNormalize(i, r);
1472  if (SR_HDL(i) & SR_INT)
1473  {
1474  mpz_set_si((mpz_ptr) n, SR_TO_INT(i));
1475  return;
1476  }
1477  if (i->s!=3)
1478  {
1479  WarnS("Omitted denominator during coefficient mapping !");
1480  }
1481  mpz_set((mpz_ptr) n, i->z);
1482 }
#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:1334
#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 2362 of file longrat.cc.

2363 {
2364  number z=ALLOC_RNUMBER();
2365 #if defined(LDEBUG)
2366  z->debug=123456;
2367 #endif
2368  mpz_init_set_si(z->z,(long)i);
2369  mpz_init_set_si(z->n,(long)j);
2370  z->s = 0;
2371  nlNormalize(z,r);
2372  return z;
2373 }
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
void nlNormalize(number &x, const coeffs r)
Definition: longrat.cc:1334
#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 2375 of file longrat.cc.

2376 {
2377  number z=ALLOC_RNUMBER();
2378 #if defined(LDEBUG)
2379  z->debug=123456;
2380 #endif
2381  mpz_init_set(z->z,i);
2382  mpz_init_set(z->n,j);
2383  z->s = 0;
2384  nlNormalize(z,r);
2385  return z;
2386 }
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
void nlNormalize(number &x, const coeffs r)
Definition: longrat.cc:1334
#define ALLOC_RNUMBER()
Definition: coeffs.h:87

§ nlInitChar()

BOOLEAN nlInitChar ( coeffs  ,
void *   
)

Definition at line 3310 of file longrat.cc.

3311 {
3312  r->is_domain=TRUE;
3313  r->rep=n_rep_gap_rat;
3314 
3315  //const int ch = (int)(long)(p);
3316 
3317  r->nCoeffIsEqual=nlCoeffIsEqual;
3318  //r->cfKillChar = ndKillChar; /* dummy */
3319  r->cfCoeffString=nlCoeffString;
3320  r->cfCoeffName=nlCoeffName;
3321 
3322  r->cfInitMPZ = nlInitMPZ;
3323  r->cfMPZ = nlMPZ;
3324 
3325  r->cfMult = nlMult;
3326  r->cfSub = nlSub;
3327  r->cfAdd = nlAdd;
3328  if (p==NULL) /* Q */
3329  {
3330  r->is_field=TRUE;
3331  r->cfDiv = nlDiv;
3332  //r->cfGcd = ndGcd_dummy;
3333  r->cfSubringGcd = nlGcd;
3334  }
3335  else /* Z: coeffs_BIGINT */
3336  {
3337  r->is_field=FALSE;
3338  r->cfDiv = nlIntDiv;
3339  r->cfIntMod= nlIntMod;
3340  r->cfGcd = nlGcd;
3341  r->cfDivBy=nlDivBy;
3342  r->cfDivComp = nlDivComp;
3343  r->cfIsUnit = nlIsUnit;
3344  r->cfGetUnit = nlGetUnit;
3345  r->cfQuot1 = nlQuot1;
3346  r->cfLcm = nlLcm;
3347  r->cfXExtGcd=nlXExtGcd;
3348  r->cfQuotRem=nlQuotRem;
3349  }
3350  r->cfExactDiv= nlExactDiv;
3351  r->cfInit = nlInit;
3352  r->cfSize = nlSize;
3353  r->cfInt = nlInt;
3354 
3355  r->cfChineseRemainder=nlChineseRemainderSym;
3356  r->cfFarey=nlFarey;
3357  r->cfInpNeg = nlNeg;
3358  r->cfInvers= nlInvers;
3359  r->cfCopy = nlCopy;
3360  r->cfRePart = nlCopy;
3361  //r->cfImPart = ndReturn0;
3362  r->cfWriteLong = nlWrite;
3363  r->cfRead = nlRead;
3364  r->cfNormalize=nlNormalize;
3365  r->cfGreater = nlGreater;
3366  r->cfEqual = nlEqual;
3367  r->cfIsZero = nlIsZero;
3368  r->cfIsOne = nlIsOne;
3369  r->cfIsMOne = nlIsMOne;
3370  r->cfGreaterZero = nlGreaterZero;
3371  r->cfPower = nlPower;
3372  r->cfGetDenom = nlGetDenom;
3373  r->cfGetNumerator = nlGetNumerator;
3374  r->cfExtGcd = nlExtGcd; // only for ring stuff and Z
3375  r->cfNormalizeHelper = nlNormalizeHelper;
3376  r->cfDelete= nlDelete;
3377  r->cfSetMap = nlSetMap;
3378  //r->cfName = ndName;
3379  r->cfInpMult=nlInpMult;
3380  r->cfInpAdd=nlInpAdd;
3381  r->cfCoeffWrite=nlCoeffWrite;
3382 
3383  r->cfClearContent = nlClearContent;
3384  r->cfClearDenominators = nlClearDenominators;
3385 
3386 #ifdef LDEBUG
3387  // debug stuff
3388  r->cfDBTest=nlDBTest;
3389 #endif
3390  r->convSingNFactoryN=nlConvSingNFactoryN;
3391  r->convFactoryNSingN=nlConvFactoryNSingN;
3392 
3393  r->cfRandom=nlRandom;
3394 
3395  // io via ssi
3396  r->cfWriteFd=nlWriteFd;
3397  r->cfReadFd=nlReadFd;
3398 
3399  // the variables: general stuff (required)
3400  r->nNULL = INT_TO_SR(0);
3401  //r->type = n_Q;
3402  r->ch = 0;
3403  r->has_simple_Alloc=FALSE;
3404  r->has_simple_Inverse=FALSE;
3405 
3406  // variables for this type of coeffs:
3407  // (none)
3408  return FALSE;
3409 }
LINLINE number nlSub(number la, number li, const coeffs r)
Definition: longrat.cc:2585
static void nlClearDenominators(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
Definition: longrat.cc:3054
#define INT_TO_SR(INT)
Definition: longrat.h:69
BOOLEAN nlCoeffIsEqual(const coeffs r, n_coeffType n, void *p)
Definition: longrat.cc:3274
char * nlCoeffName(const coeffs r)
Definition: longrat.cc:3148
static number nlConvFactoryNSingN(const CanonicalForm f, const coeffs r)
Definition: longrat.cc:376
BOOLEAN nlGreaterZero(number za, const coeffs r)
Definition: longrat.cc:1155
#define FALSE
Definition: auxiliary.h:95
static void nlMPZ(mpz_t m, number &n, const coeffs r)
Definition: longrat.cc:2637
return P p
Definition: myNF.cc:203
number nlNormalizeHelper(number a, number b, const coeffs r)
Definition: longrat.cc:1378
LINLINE void nlInpAdd(number &a, number b, const coeffs r)
Definition: longrat.cc:2537
number nlGetDenom(number &n, const coeffs r)
Definition: longrat.cc:1488
void nlWrite(number a, const coeffs r)
Definition: longrat0.cc:116
int nlSize(number a, const coeffs)
Definition: longrat.cc:576
LINLINE number nlAdd(number la, number li, const coeffs r)
Definition: longrat.cc:2519
BOOLEAN nlIsMOne(number a, const coeffs r)
Definition: longrat.cc:1180
void nlCoeffWrite(const coeffs r, BOOLEAN details)
Definition: longrat.cc:2914
number nlIntDiv(number a, number b, const coeffs r)
Definition: longrat.cc:786
number nlGcd(number a, number b, const coeffs r)
Definition: longrat.cc:1192
#define TRUE
Definition: auxiliary.h:99
coeffs nlQuot1(number c, const coeffs r)
Definition: longrat.cc:958
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:867
BOOLEAN nlGreater(number a, number b, const coeffs r)
Definition: longrat.cc:1165
static number nlInitMPZ(mpz_t m, const coeffs)
Definition: longrat.cc:2646
LINLINE BOOLEAN nlIsOne(number a, const coeffs r)
Definition: longrat.cc:2442
static number nlLcm(number a, number b, const coeffs r)
Definition: longrat.cc:3286
const ring r
Definition: syzextra.cc:208
LINLINE number nlNeg(number za, const coeffs r)
Definition: longrat.cc:2500
number nlXExtGcd(number a, number b, number *s, number *t, number *u, number *v, const coeffs r)
Definition: longrat.cc:2658
number nlDiv(number a, number b, const coeffs r)
Definition: longrat.cc:992
LINLINE number nlMult(number a, number b, const coeffs r)
Definition: longrat.cc:2555
number nlInvers(number a, const coeffs r)
Definition: longrat.cc:655
int nlDivComp(number a, number b, const coeffs r)
Definition: longrat.cc:942
LINLINE void nlInpMult(number &a, number b, const coeffs r)
Definition: longrat.cc:2603
static void nlWriteFd(number n, FILE *f, const coeffs)
Definition: longrat.cc:3166
LINLINE BOOLEAN nlEqual(number a, number b, const coeffs r)
Definition: longrat.cc:2415
void nlPower(number x, int exp, number *lu, const coeffs r)
Definition: longrat.cc:1102
number nlQuotRem(number a, number b, number *r, const coeffs R)
Definition: longrat.cc:2710
static number nlReadFd(s_buff f, const coeffs)
Definition: longrat.cc:3212
number nlExtGcd(number a, number b, number *s, number *t, const coeffs)
Definition: longrat.cc:2865
LINLINE BOOLEAN nlIsZero(number za, const coeffs r)
Definition: longrat.cc:2451
static void nlClearContent(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
Definition: longrat.cc:2963
static CanonicalForm nlConvSingNFactoryN(number n, const BOOLEAN setChar, const coeffs)
Definition: longrat.cc:338
number nlGetUnit(number, const coeffs)
Definition: longrat.cc:953
(number), see longrat.h
Definition: coeffs.h:111
void nlNormalize(number &x, const coeffs r)
Definition: longrat.cc:1334
number nlChineseRemainderSym(number *x, number *q, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs CF)
Definition: longrat.cc:2923
#define NULL
Definition: omList.c:10
static number nlRandom(siRandProc p, number v2, number, const coeffs cf)
Definition: longrat.cc:3296
LINLINE void nlDelete(number *a, const coeffs r)
Definition: longrat.cc:2484
BOOLEAN nlDivBy(number a, number b, const coeffs)
Definition: longrat.cc:928
BOOLEAN nlIsUnit(number a, const coeffs)
Definition: longrat.cc:983
long nlInt(number &n, const coeffs r)
Definition: longrat.cc:605
nMapFunc nlSetMap(const coeffs src, const coeffs dst)
Definition: longrat.cc:2311
number nlExactDiv(number a, number b, const coeffs r)
Definition: longrat.cc:735
BOOLEAN nlDBTest(number a, const char *f, const int l)
LINLINE number nlInit(long i, const coeffs r)
Definition: longrat.cc:2424
static char * nlCoeffString(const coeffs r)
Definition: longrat.cc:3154
number nlGetNumerator(number &n, const coeffs r)
Definition: longrat.cc:1517
LINLINE number nlCopy(number a, const coeffs r)
Definition: longrat.cc:2471
number nlFarey(number nN, number nP, const coeffs CF)
Definition: longrat.cc:2796

§ nlInpGcd()

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

Definition at line 2763 of file longrat.cc.

2764 {
2765  if ((SR_HDL(b)|SR_HDL(a))&SR_INT)
2766  {
2767  number n=nlGcd(a,b,r);
2768  nlDelete(&a,r);
2769  a=n;
2770  }
2771  else
2772  {
2773  mpz_gcd(a->z,a->z,b->z);
2775  }
2776 }
const poly a
Definition: syzextra.cc:212
number nlGcd(number a, number b, const coeffs r)
Definition: longrat.cc:1192
number nlShort3_noinline(number x)
Definition: longrat.cc:170
LINLINE void nlDelete(number *a, const coeffs r)
Definition: longrat.cc:2484
#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:99
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 1425 of file longrat.cc.

1426 {
1427  const int p = n_GetChar(Zp);
1428  assume( p > 0 );
1429 
1430  const long P = p;
1431  assume( P > 0 );
1432 
1433  // embedded long within q => only long numerator has to be converted
1434  // to int (modulo char.)
1435  if (SR_HDL(q) & SR_INT)
1436  {
1437  long i = SR_TO_INT(q);
1438  return n_Init( i, Zp );
1439  }
1440 
1441  const unsigned long PP = p;
1442 
1443  // numerator modulo char. should fit into int
1444  number z = n_Init( static_cast<long>(mpz_fdiv_ui(q->z, PP)), Zp );
1445 
1446  // denominator != 1?
1447  if (q->s!=3)
1448  {
1449  // denominator modulo char. should fit into int
1450  number n = n_Init( static_cast<long>(mpz_fdiv_ui(q->n, PP)), Zp );
1451 
1452  number res = n_Div( z, n, Zp );
1453 
1454  n_Delete(&z, Zp);
1455  n_Delete(&n, Zp);
1456 
1457  return res;
1458  }
1459 
1460  return z;
1461 }
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 1334 of file longrat.cc.

1335 {
1336  if ((SR_HDL(x) & SR_INT) ||(x==NULL))
1337  return;
1338  if (x->s==3)
1339  {
1341  nlTest(x,r);
1342  return;
1343  }
1344  else if (x->s==0)
1345  {
1346  if (mpz_cmp_si(x->n,1L)==0)
1347  {
1348  mpz_clear(x->n);
1349  x->s=3;
1350  x=nlShort3(x);
1351  }
1352  else
1353  {
1354  mpz_t gcd;
1355  mpz_init(gcd);
1356  mpz_gcd(gcd,x->z,x->n);
1357  x->s=1;
1358  if (mpz_cmp_si(gcd,1L)!=0)
1359  {
1360  mpz_divexact(x->z,x->z,gcd);
1361  mpz_divexact(x->n,x->n,gcd);
1362  if (mpz_cmp_si(x->n,1L)==0)
1363  {
1364  mpz_clear(x->n);
1365  x->s=3;
1367  }
1368  }
1369  mpz_clear(gcd);
1370  }
1371  }
1372  nlTest(x, r);
1373 }
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