My Project
Data Structures | Macros | Functions
longrat.h File Reference
#include "misc/auxiliary.h"
#include "coeffs/si_gmp.h"
#include "coeffs/coeffs.h"
#include "factory/si_log2.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)
 
void nlMPZ (mpz_t m, number &n, 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...
 
number nlChineseRemainderSym (number *x, number *q, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs CF)
 

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 48 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 68 of file longrat.h.

◆ MP_SMALL

#define MP_SMALL   1

Definition at line 71 of file longrat.h.

◆ SR_HDL

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

Definition at line 65 of file longrat.h.

◆ SR_INT

#define SR_INT   1L

Definition at line 67 of file longrat.h.

◆ SR_TO_INT

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

Definition at line 69 of file longrat.h.

Function Documentation

◆ nlChineseRemainderSym()

number nlChineseRemainderSym ( number *  x,
number *  q,
int  rl,
BOOLEAN  sym,
CFArray inv_cache,
const coeffs  CF 
)

Definition at line 3053 of file longrat.cc.

3055{
3056 setCharacteristic( 0 ); // only in char 0
3058 CFArray X(rl), Q(rl);
3059 int i;
3060 for(i=rl-1;i>=0;i--)
3061 {
3062 X[i]=CF->convSingNFactoryN(x[i],FALSE,CF); // may be larger MAX_INT
3063 Q[i]=CF->convSingNFactoryN(q[i],FALSE,CF); // may be larger MAX_INT
3064 }
3065 CanonicalForm xnew,qnew;
3066 if (n_SwitchChinRem)
3067 chineseRemainder(X,Q,xnew,qnew);
3068 else
3069 chineseRemainderCached(X,Q,xnew,qnew,inv_cache);
3070 number n=CF->convFactoryNSingN(xnew,CF);
3071 if (sym)
3072 {
3073 number p=CF->convFactoryNSingN(qnew,CF);
3074 number p2;
3075 if (getCoeffType(CF) == n_Q) p2=nlIntDiv(p,nlInit(2, CF),CF);
3076 else p2=CF->cfDiv(p,CF->cfInit(2, CF),CF);
3077 if (CF->cfGreater(n,p2,CF))
3078 {
3079 number n2=CF->cfSub(n,p,CF);
3080 CF->cfDelete(&n,CF);
3081 n=n2;
3082 }
3083 CF->cfDelete(&p2,CF);
3084 CF->cfDelete(&p,CF);
3085 }
3086 CF->cfNormalize(n,CF);
3087 return n;
3088}
#define FALSE
Definition: auxiliary.h:96
void Off(int sw)
switches
void FACTORY_PUBLIC setCharacteristic(int c)
Definition: cf_char.cc:28
int i
Definition: cfEzgcd.cc:132
Variable x
Definition: cfModGcd.cc:4084
int p
Definition: cfModGcd.cc:4080
void FACTORY_PUBLIC chineseRemainder(const CanonicalForm &x1, const CanonicalForm &q1, const CanonicalForm &x2, const CanonicalForm &q2, CanonicalForm &xnew, CanonicalForm &qnew)
void chineseRemainder ( const CanonicalForm & x1, const CanonicalForm & q1, const CanonicalForm & x2,...
Definition: cf_chinese.cc:57
void FACTORY_PUBLIC chineseRemainderCached(const CanonicalForm &x1, const CanonicalForm &q1, const CanonicalForm &x2, const CanonicalForm &q2, CanonicalForm &xnew, CanonicalForm &qnew, CFArray &inv)
Definition: cf_chinese.cc:308
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:30
factory's main class
Definition: canonicalform.h:86
@ n_Q
rational (GMP) numbers
Definition: coeffs.h:31
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
STATIC_VAR jList * Q
Definition: janet.cc:30
VAR int n_SwitchChinRem
Definition: longrat.cc:3052
number nlIntDiv(number a, number b, const coeffs r)
Definition: longrat.cc:898
LINLINE number nlInit(long i, const coeffs r)
Definition: longrat.cc:2566

◆ nlDelete()

void nlDelete ( number *  a,
const coeffs  r 
)

Definition at line 2626 of file longrat.cc.

2627{
2628 if (*a!=NULL)
2629 {
2630 nlTest(*a, r);
2631 if ((SR_HDL(*a) & SR_INT)==0)
2632 {
2633 _nlDelete_NoImm(a);
2634 }
2635 *a=NULL;
2636 }
2637}
#define NULL
Definition: auxiliary.h:104
#define nlTest(a, r)
Definition: longrat.cc:87
void _nlDelete_NoImm(number *a)
Definition: longrat.cc:1729
#define SR_INT
Definition: longrat.h:67
#define SR_HDL(A)
Definition: tgb.cc:35

◆ nlGetDenom()

number nlGetDenom ( number &  n,
const coeffs  r 
)

Definition at line 1601 of file longrat.cc.

1602{
1603 if (!(SR_HDL(n) & SR_INT))
1604 {
1605 if (n->s==0)
1606 {
1607 nlNormalize(n,r);
1608 }
1609 if (!(SR_HDL(n) & SR_INT))
1610 {
1611 if (n->s!=3)
1612 {
1613 number u=ALLOC_RNUMBER();
1614 u->s=3;
1615#if defined(LDEBUG)
1616 u->debug=123456;
1617#endif
1618 mpz_init_set(u->z,n->n);
1619 u=nlShort3_noinline(u);
1620 return u;
1621 }
1622 }
1623 }
1624 return INT_TO_SR(1);
1625}
#define ALLOC_RNUMBER()
Definition: coeffs.h:88
number nlShort3_noinline(number x)
Definition: longrat.cc:159
void nlNormalize(number &x, const coeffs r)
Definition: longrat.cc:1447
#define INT_TO_SR(INT)
Definition: longrat.h:68

◆ nlGetNumerator()

number nlGetNumerator ( number &  n,
const coeffs  r 
)

Definition at line 1630 of file longrat.cc.

1631{
1632 if (!(SR_HDL(n) & SR_INT))
1633 {
1634 if (n->s==0)
1635 {
1636 nlNormalize(n,r);
1637 }
1638 if (!(SR_HDL(n) & SR_INT))
1639 {
1640 number u=ALLOC_RNUMBER();
1641#if defined(LDEBUG)
1642 u->debug=123456;
1643#endif
1644 u->s=3;
1645 mpz_init_set(u->z,n->z);
1646 if (n->s!=3)
1647 {
1648 u=nlShort3_noinline(u);
1649 }
1650 return u;
1651 }
1652 }
1653 return n; // imm. int
1654}

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

2505{
2506 number z=ALLOC_RNUMBER();
2507#if defined(LDEBUG)
2508 z->debug=123456;
2509#endif
2510 mpz_init_set_si(z->z,(long)i);
2511 mpz_init_set_si(z->n,(long)j);
2512 z->s = 0;
2513 nlNormalize(z,r);
2514 return z;
2515}
int j
Definition: facHensel.cc:110

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

2518{
2519 number z=ALLOC_RNUMBER();
2520#if defined(LDEBUG)
2521 z->debug=123456;
2522#endif
2523 mpz_init_set(z->z,i);
2524 mpz_init_set(z->n,j);
2525 z->s = 0;
2526 nlNormalize(z,r);
2527 return z;
2528}

◆ nlInitChar()

BOOLEAN nlInitChar ( coeffs  r,
void *  p 
)

Definition at line 3433 of file longrat.cc.

3434{
3435 r->is_domain=TRUE;
3436 r->rep=n_rep_gap_rat;
3437
3438 r->nCoeffIsEqual=nlCoeffIsEqual;
3439 //r->cfKillChar = ndKillChar; /* dummy */
3440 //r->cfCoeffString=nlCoeffString;
3441 r->cfCoeffName=nlCoeffName;
3442
3443 r->cfInitMPZ = nlInitMPZ;
3444 r->cfMPZ = nlMPZ;
3445
3446 r->cfMult = nlMult;
3447 r->cfSub = nlSub;
3448 r->cfAdd = nlAdd;
3449 r->cfExactDiv= nlExactDiv;
3450 if (p==NULL) /* Q */
3451 {
3452 r->is_field=TRUE;
3453 r->cfDiv = nlDiv;
3454 //r->cfGcd = ndGcd_dummy;
3455 r->cfSubringGcd = nlGcd;
3456 }
3457 else /* Z: coeffs_BIGINT */
3458 {
3459 r->is_field=FALSE;
3460 r->cfDiv = nlIntDiv;
3461 r->cfIntMod= nlIntMod;
3462 r->cfGcd = nlGcd;
3463 r->cfDivBy=nlDivBy;
3464 r->cfDivComp = nlDivComp;
3465 r->cfIsUnit = nlIsUnit;
3466 r->cfGetUnit = nlGetUnit;
3467 r->cfQuot1 = nlQuot1;
3468 r->cfLcm = nlLcm;
3469 r->cfXExtGcd=nlXExtGcd;
3470 r->cfQuotRem=nlQuotRem;
3471 }
3472 r->cfInit = nlInit;
3473 r->cfSize = nlSize;
3474 r->cfInt = nlInt;
3475
3476 r->cfChineseRemainder=nlChineseRemainderSym;
3477 r->cfFarey=nlFarey;
3478 r->cfInpNeg = nlNeg;
3479 r->cfInvers= nlInvers;
3480 r->cfCopy = nlCopy;
3481 r->cfRePart = nlCopy;
3482 //r->cfImPart = ndReturn0;
3483 r->cfWriteLong = nlWrite;
3484 r->cfRead = nlRead;
3485 r->cfNormalize=nlNormalize;
3486 r->cfGreater = nlGreater;
3487 r->cfEqual = nlEqual;
3488 r->cfIsZero = nlIsZero;
3489 r->cfIsOne = nlIsOne;
3490 r->cfIsMOne = nlIsMOne;
3491 r->cfGreaterZero = nlGreaterZero;
3492 r->cfPower = nlPower;
3493 r->cfGetDenom = nlGetDenom;
3494 r->cfGetNumerator = nlGetNumerator;
3495 r->cfExtGcd = nlExtGcd; // only for ring stuff and Z
3496 r->cfNormalizeHelper = nlNormalizeHelper;
3497 r->cfDelete= nlDelete;
3498 r->cfSetMap = nlSetMap;
3499 //r->cfName = ndName;
3500 r->cfInpMult=nlInpMult;
3501 r->cfInpAdd=nlInpAdd;
3502 //r->cfCoeffWrite=nlCoeffWrite;
3503
3504 r->cfClearContent = nlClearContent;
3505 r->cfClearDenominators = nlClearDenominators;
3506
3507#ifdef LDEBUG
3508 // debug stuff
3509 r->cfDBTest=nlDBTest;
3510#endif
3511 r->convSingNFactoryN=nlConvSingNFactoryN;
3512 r->convFactoryNSingN=nlConvFactoryNSingN;
3513
3514 r->cfRandom=nlRandom;
3515
3516 // io via ssi
3517 r->cfWriteFd=nlWriteFd;
3518 r->cfReadFd=nlReadFd;
3519
3520 //r->type = n_Q;
3521 r->ch = 0;
3522 r->has_simple_Alloc=FALSE;
3523 r->has_simple_Inverse=FALSE;
3524
3525 // variables for this type of coeffs:
3526 // (none)
3527 return FALSE;
3528}
#define TRUE
Definition: auxiliary.h:100
@ n_rep_gap_rat
(number), see longrat.h
Definition: coeffs.h:112
void nlWriteFd(number n, const ssiInfo *d, const coeffs)
Definition: longrat.cc:3288
LINLINE void nlInpMult(number &a, number b, const coeffs r)
Definition: longrat.cc:2745
LINLINE BOOLEAN nlEqual(number a, number b, const coeffs r)
Definition: longrat.cc:2557
LINLINE number nlAdd(number la, number li, const coeffs r)
Definition: longrat.cc:2661
long nlInt(number &n, const coeffs r)
Definition: longrat.cc:701
static number nlLcm(number a, number b, const coeffs r)
Definition: longrat.cc:3409
LINLINE number nlSub(number la, number li, const coeffs r)
Definition: longrat.cc:2727
number nlIntMod(number a, number b, const coeffs r)
Definition: longrat.cc:979
LINLINE number nlCopy(number a, const coeffs r)
Definition: longrat.cc:2613
LINLINE number nlNeg(number za, const coeffs r)
Definition: longrat.cc:2642
number nlXExtGcd(number a, number b, number *s, number *t, number *u, number *v, const coeffs r)
Definition: longrat.cc:2788
void nlPower(number x, int exp, number *lu, const coeffs r)
Definition: longrat.cc:1215
number nlQuotRem(number a, number b, number *r, const coeffs R)
Definition: longrat.cc:2840
number nlFarey(number nN, number nP, const coeffs CF)
Definition: longrat.cc:2926
LINLINE BOOLEAN nlIsOne(number a, const coeffs r)
Definition: longrat.cc:2584
number nlNormalizeHelper(number a, number b, const coeffs r)
Definition: longrat.cc:1491
LINLINE void nlDelete(number *a, const coeffs r)
Definition: longrat.cc:2626
BOOLEAN nlGreaterZero(number za, const coeffs r)
Definition: longrat.cc:1268
LINLINE void nlInpAdd(number &a, number b, const coeffs r)
Definition: longrat.cc:2679
number nlExactDiv(number a, number b, const coeffs r)
Definition: longrat.cc:831
const char * nlRead(const char *s, number *a, const coeffs r)
Definition: longrat0.cc:31
void nlMPZ(mpz_t m, number &n, const coeffs r)
Definition: longrat.cc:2779
number nlInvers(number a, const coeffs r)
Definition: longrat.cc:751
BOOLEAN nlIsUnit(number a, const coeffs)
Definition: longrat.cc:1096
static number nlConvFactoryNSingN(const CanonicalForm f, const coeffs r)
Definition: longrat.cc:368
number nlChineseRemainderSym(number *x, number *q, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs CF)
Definition: longrat.cc:3053
int nlDivComp(number a, number b, const coeffs r)
Definition: longrat.cc:1054
char * nlCoeffName(const coeffs r)
Definition: longrat.cc:3282
number nlExtGcd(number a, number b, number *s, number *t, const coeffs)
Definition: longrat.cc:2997
LINLINE number nlMult(number a, number b, const coeffs r)
Definition: longrat.cc:2697
static number nlInitMPZ(mpz_t m, const coeffs)
Definition: longrat.cc:164
static void nlClearDenominators(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
Definition: longrat.cc:3188
LINLINE BOOLEAN nlIsZero(number za, const coeffs r)
Definition: longrat.cc:2593
number nlGetDenom(number &n, const coeffs r)
Definition: longrat.cc:1601
number nlGcd(number a, number b, const coeffs r)
Definition: longrat.cc:1305
number nlReadFd(const ssiInfo *d, const coeffs)
Definition: longrat.cc:3334
int nlSize(number a, const coeffs)
Definition: longrat.cc:672
nMapFunc nlSetMap(const coeffs src, const coeffs dst)
Definition: longrat.cc:2446
BOOLEAN nlDBTest(number a, const char *f, const int l)
number nlDiv(number a, number b, const coeffs r)
Definition: longrat.cc:1105
BOOLEAN nlIsMOne(number a, const coeffs r)
Definition: longrat.cc:1293
static void nlClearContent(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
Definition: longrat.cc:3097
number nlGetNumerator(number &n, const coeffs r)
Definition: longrat.cc:1630
BOOLEAN nlCoeffIsEqual(const coeffs r, n_coeffType n, void *p)
Definition: longrat.cc:3397
static CanonicalForm nlConvSingNFactoryN(number n, const BOOLEAN setChar, const coeffs)
Definition: longrat.cc:330
number nlGetUnit(number n, const coeffs cf)
Definition: longrat.cc:1065
coeffs nlQuot1(number c, const coeffs r)
Definition: longrat.cc:1071
BOOLEAN nlGreater(number a, number b, const coeffs r)
Definition: longrat.cc:1278
BOOLEAN nlDivBy(number a, number b, const coeffs)
Definition: longrat.cc:1040
void nlWrite(number a, const coeffs r)
Definition: longrat0.cc:90
static number nlRandom(siRandProc p, number v2, number, const coeffs cf)
Definition: longrat.cc:3419

◆ nlInpGcd()

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

Definition at line 2893 of file longrat.cc.

2894{
2895 if ((SR_HDL(b)|SR_HDL(a))&SR_INT)
2896 {
2897 number n=nlGcd(a,b,r);
2898 nlDelete(&a,r);
2899 a=n;
2900 }
2901 else
2902 {
2903 mpz_gcd(a->z,a->z,b->z);
2904 a=nlShort3_noinline(a);
2905 }
2906}
CanonicalForm b
Definition: cfModGcd.cc:4105

◆ nlIsInteger()

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

Definition at line 94 of file longrat.h.

95{
96 assume( nCoeff_is_Q (r) );
97 n_Test(q, r);
98
99 if (SR_HDL(q) & SR_INT)
100 return TRUE; // immediate int
101
102 return ( q->s == 3 );
103}
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:736
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:830
#define SR_HDL(A)
Definition: longrat.h:65
#define assume(x)
Definition: mod2.h:387

◆ nlModP()

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

Definition at line 1538 of file longrat.cc.

1539{
1540 const int p = n_GetChar(Zp);
1541 assume( p > 0 );
1542
1543 const long P = p;
1544 assume( P > 0 );
1545
1546 // embedded long within q => only long numerator has to be converted
1547 // to int (modulo char.)
1548 if (SR_HDL(q) & SR_INT)
1549 {
1550 long i = SR_TO_INT(q);
1551 return n_Init( i, Zp );
1552 }
1553
1554 const unsigned long PP = p;
1555
1556 // numerator modulo char. should fit into int
1557 number z = n_Init( static_cast<long>(mpz_fdiv_ui(q->z, PP)), Zp );
1558
1559 // denominator != 1?
1560 if (q->s!=3)
1561 {
1562 // denominator modulo char. should fit into int
1563 number n = n_Init( static_cast<long>(mpz_fdiv_ui(q->n, PP)), Zp );
1564
1565 number res = n_Div( z, n, Zp );
1566
1567 n_Delete(&z, Zp);
1568 n_Delete(&n, Zp);
1569
1570 return res;
1571 }
1572
1573 return z;
1574}
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
Definition: coeffs.h:616
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:445
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:456
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:539
CanonicalForm res
Definition: facAbsFact.cc:60
#define SR_TO_INT(SR)
Definition: longrat.h:69

◆ nlMPZ()

void nlMPZ ( mpz_t  m,
number &  n,
const coeffs  r 
)

Definition at line 2779 of file longrat.cc.

2780{
2781 nlTest(n, r);
2782 nlNormalize(n, r);
2783 if (SR_HDL(n) & SR_INT) mpz_init_set_si(m, SR_TO_INT(n)); /* n fits in an int */
2784 else mpz_init_set(m, (mpz_ptr)n->z);
2785}
int m
Definition: cfEzgcd.cc:128

◆ nlNormalize()

void nlNormalize ( number &  x,
const coeffs  r 
)

Definition at line 1447 of file longrat.cc.

1448{
1449 if ((SR_HDL(x) & SR_INT) ||(x==NULL))
1450 return;
1451 if (x->s==3)
1452 {
1454 nlTest(x,r);
1455 return;
1456 }
1457 else if (x->s==0)
1458 {
1459 if (mpz_cmp_si(x->n,1L)==0)
1460 {
1461 mpz_clear(x->n);
1462 x->s=3;
1463 x=nlShort3(x);
1464 }
1465 else
1466 {
1467 mpz_t gcd;
1468 mpz_init(gcd);
1469 mpz_gcd(gcd,x->z,x->n);
1470 x->s=1;
1471 if (mpz_cmp_si(gcd,1L)!=0)
1472 {
1473 mpz_divexact(x->z,x->z,gcd);
1474 mpz_divexact(x->n,x->n,gcd);
1475 if (mpz_cmp_si(x->n,1L)==0)
1476 {
1477 mpz_clear(x->n);
1478 x->s=3;
1480 }
1481 }
1482 mpz_clear(gcd);
1483 }
1484 }
1485 nlTest(x, r);
1486}
CanonicalForm FACTORY_PUBLIC gcd(const CanonicalForm &, const CanonicalForm &)
Definition: cf_gcd.cc:685
static number nlShort3(number x)
Definition: longrat.cc:109

◆ nlQlogSize()

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

only used by slimgb (tgb.cc)

Definition at line 76 of file longrat.h.

77{
78 assume( nCoeff_is_Q (r) );
79
80 if(SR_HDL(n)&SR_INT)
81 {
82 if (SR_HDL(n)==SR_INT) return 0;
83 long i = SR_TO_INT (n);
84 unsigned long v;
85 v = ABS(i);
86 return SI_LOG2_LONG(v) + 1;
87 }
88 //assume denominator is 0
89 number nn=(number) n;
90 return mpz_sizeinbase (nn->z, 2);
91}
static int ABS(int v)
Definition: auxiliary.h:112
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39
static int SI_LOG2_LONG(long v)
Definition: si_log2.h:22