 |
My Project
UNKNOWN_GIT_VERSION
|
Go to the source code of this file.
|
LINLINE BOOLEAN | nlEqual (number a, number b, const coeffs r) |
|
LINLINE number | nlInit (long i, const coeffs r) |
|
LINLINE BOOLEAN | nlIsOne (number a, const coeffs r) |
|
LINLINE BOOLEAN | nlIsZero (number za, const coeffs r) |
|
LINLINE number | nlCopy (number a, const coeffs r) |
|
LINLINE number | nl_Copy (number a, const coeffs r) |
|
LINLINE void | nlDelete (number *a, const coeffs r) |
|
LINLINE number | nlNeg (number za, const coeffs r) |
|
LINLINE number | nlAdd (number la, number li, const coeffs r) |
|
LINLINE number | nlSub (number la, number li, const coeffs r) |
|
LINLINE number | nlMult (number a, number b, const coeffs r) |
|
LINLINE void | nlInpAdd (number &a, number b, const coeffs r) |
|
LINLINE void | nlInpMult (number &a, number b, const coeffs r) |
|
number | nlRInit (long i) |
|
void | nlNormalize (number &x, const coeffs r) |
|
number | nlGcd (number a, number b, const coeffs r) |
|
number | nlExtGcd (number a, number b, number *s, number *t, const coeffs) |
|
number | nlNormalizeHelper (number a, number b, const coeffs r) |
|
BOOLEAN | nlGreater (number a, number b, const coeffs r) |
|
BOOLEAN | nlIsMOne (number a, const coeffs r) |
|
long | nlInt (number &n, const coeffs r) |
|
number | nlBigInt (number &n) |
|
number | nlMapGMP (number from, const coeffs src, const coeffs dst) |
|
BOOLEAN | nlGreaterZero (number za, const coeffs r) |
|
number | nlInvers (number a, const coeffs r) |
|
number | nlDiv (number a, number b, const coeffs r) |
|
number | nlExactDiv (number a, number b, const coeffs r) |
|
number | nlIntDiv (number a, number b, const coeffs r) |
|
number | nlIntMod (number a, number b, const coeffs r) |
|
void | nlPower (number x, int exp, number *lu, const coeffs r) |
|
const char * | nlRead (const char *s, number *a, const coeffs r) |
|
void | nlWrite (number a, const coeffs r) |
|
void | nlCoeffWrite (const coeffs r, BOOLEAN details) |
|
number | nlFarey (number nN, number nP, const coeffs CF) |
|
BOOLEAN | nlDBTest (number a, const char *f, const int l) |
|
nMapFunc | nlSetMap (const coeffs src, const coeffs dst) |
|
void | nlInpIntDiv (number &a, number b, const coeffs r) |
|
BOOLEAN | nlDBTest (number a, const char *f, int l, const coeffs r) |
|
static number | nlShort3 (number x) |
|
void | _nlDelete_NoImm (number *a) |
|
number | nlShort3_noinline (number x) |
|
void | mpz_mul_si (mpz_ptr r, mpz_srcptr s, long int si) |
|
static number | nlMapP (number from, const coeffs src, const coeffs dst) |
|
static number | nlMapLongR (number from, const coeffs src, const coeffs dst) |
|
static number | nlMapR (number from, const coeffs src, const coeffs dst) |
|
number | nlMapZ (number from, const coeffs src, const coeffs dst) |
|
number | nlMapMachineInt (number from, const coeffs, const coeffs) |
|
static CanonicalForm | nlConvSingNFactoryN (number n, const BOOLEAN setChar, const coeffs) |
|
static number | nlConvFactoryNSingN (const CanonicalForm f, const coeffs r) |
|
int | nlSize (number a, const coeffs) |
|
number | nlBigInt (number &i, const coeffs r) |
|
BOOLEAN | nlDivBy (number a, number b, const coeffs) |
|
int | nlDivComp (number a, number b, const coeffs r) |
|
number | nlGetUnit (number n, const coeffs cf) |
|
coeffs | nlQuot1 (number c, const coeffs r) |
|
BOOLEAN | nlIsUnit (number a, const coeffs) |
|
static int | int_extgcd (int a, int b, int *u, int *x, int *v, int *y) |
|
number | nlShort1 (number x) |
|
number | nlModP (number q, const coeffs, const coeffs Zp) |
|
void | nlGMP (number &i, mpz_t n, const coeffs r) |
|
number | nlGetDenom (number &n, const coeffs r) |
|
number | nlGetNumerator (number &n, const coeffs r) |
|
BOOLEAN | _nlEqual_aNoImm_OR_bNoImm (number a, number b) |
|
number | _nlCopy_NoImm (number a) |
|
number | _nlNeg_NoImm (number a) |
|
static void | nlNormalize_Gcd (number &x) |
|
number | _nlAdd_aNoImm_OR_bNoImm (number a, number b) |
|
void | _nlInpAdd_aNoImm_OR_bNoImm (number &a, number b) |
|
number | _nlSub_aNoImm_OR_bNoImm (number a, number b) |
|
number | _nlMult_aImm_bImm_rNoImm (number a, number b) |
|
number | _nlMult_aNoImm_OR_bNoImm (number a, number b) |
|
number | nlCopyMap (number a, const coeffs, const coeffs) |
|
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...
|
|
static void | nlMPZ (mpz_t m, number &n, const coeffs r) |
|
static number | nlInitMPZ (mpz_t m, const coeffs) |
|
number | nlXExtGcd (number a, number b, number *s, number *t, number *u, number *v, const coeffs r) |
|
number | nlQuotRem (number a, number b, number *r, const coeffs R) |
|
void | nlInpGcd (number &a, number b, const coeffs r) |
|
number | nlChineseRemainderSym (number *x, number *q, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs CF) |
|
static void | nlClearContent (ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf) |
|
static void | nlClearDenominators (ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf) |
|
char * | nlCoeffName (const coeffs r) |
|
static char * | nlCoeffString (const coeffs r) |
|
void | nlWriteFd (number n, const ssiInfo *d, const coeffs) |
|
number | nlReadFd (const ssiInfo *d, const coeffs) |
|
BOOLEAN | nlCoeffIsEqual (const coeffs r, n_coeffType n, void *p) |
|
static number | nlLcm (number a, number b, const coeffs r) |
|
static number | nlRandom (siRandProc p, number v2, number, const coeffs cf) |
|
BOOLEAN | nlInitChar (coeffs r, void *p) |
|
◆ BYTES_PER_MP_LIMB
#define BYTES_PER_MP_LIMB sizeof(mp_limb_t) |
◆ GCD_NORM_COND
◆ LINLINE
◆ LONG
◆ LONGRAT_CC
◆ MAX_NUM_SIZE
◆ MP_SMALL
◆ mpz_isNeg
#define mpz_isNeg |
( |
|
A | ) |
((A)->_mp_size<0) |
◆ mpz_limb_d
#define mpz_limb_d |
( |
|
A | ) |
((A)->_mp_d) |
◆ mpz_limb_size
#define mpz_limb_size |
( |
|
A | ) |
((A)->_mp_size) |
◆ nlTest
#define nlTest |
( |
|
a, |
|
|
|
r |
|
) |
| nlDBTest(a,__FILE__,__LINE__, r) |
◆ POW_2_28
#define POW_2_28 (1L<<28) |
◆ POW_2_28_32
#define POW_2_28_32 (1L<<28) |
◆ _nlAdd_aNoImm_OR_bNoImm()
number _nlAdd_aNoImm_OR_bNoImm |
( |
number |
a, |
|
|
number |
b |
|
) |
| |
Definition at line 1683 of file longrat.cc.
1706 mpz_add(u->z,
b->z,
x);
1714 if (mpz_cmp(u->z,
b->n)==0)
1720 mpz_init_set(u->n,
b->n);
1752 mpz_mul(
x,
b->z,a->n);
1753 mpz_mul(u->z,a->z,
b->n);
1754 mpz_add(u->z,u->z,
x);
1764 mpz_mul(u->n,a->n,
b->n);
1765 if (mpz_cmp(u->z,u->n)==0)
1778 mpz_mul(u->z,
b->z,a->n);
1779 mpz_add(u->z,u->z,a->z);
1786 if (mpz_cmp(u->z,a->n)==0)
1792 mpz_init_set(u->n,a->n);
1807 mpz_mul(u->z,a->z,
b->n);
1808 mpz_add(u->z,u->z,
b->z);
1815 if (mpz_cmp(u->z,
b->n)==0)
1821 mpz_init_set(u->n,
b->n);
1828 mpz_add(u->z,a->z,
b->z);
◆ _nlCopy_NoImm()
number _nlCopy_NoImm |
( |
number |
a | ) |
|
Definition at line 1606 of file longrat.cc.
1618 mpz_init_set(
b->n,a->n);
1620 mpz_init_set(
b->z,a->z);
◆ _nlDelete_NoImm()
void _nlDelete_NoImm |
( |
number * |
a | ) |
|
Definition at line 1627 of file longrat.cc.
1642 memset(*a,0,
sizeof(**a));
◆ _nlEqual_aNoImm_OR_bNoImm()
BOOLEAN _nlEqual_aNoImm_OR_bNoImm |
( |
number |
a, |
|
|
number |
b |
|
) |
| |
Definition at line 1559 of file longrat.cc.
1566 if (a->s!=0)
return FALSE;
1567 number n=
b;
b=a; a=n;
1581 bo=(mpz_cmp(bb,
b->z)==0);
1586 if (((a->s==1) && (
b->s==3))
1587 || ((
b->s==1) && (a->s==3)))
1595 mpz_init_set(aa,a->z);
1596 mpz_init_set(bb,
b->z);
1597 if (a->s<2) mpz_mul(bb,bb,a->n);
1598 if (
b->s<2) mpz_mul(aa,aa,
b->n);
1599 bo=(mpz_cmp(aa,bb)==0);
◆ _nlInpAdd_aNoImm_OR_bNoImm()
void _nlInpAdd_aNoImm_OR_bNoImm |
( |
number & |
a, |
|
|
number |
b |
|
) |
| |
Definition at line 1841 of file longrat.cc.
1853 mpz_add(a->z,a->z,
x);
1887 mpz_add(u->z,
b->z,
x);
1890 mpz_init_set(u->n,
b->n);
1926 mpz_mul(
x,
b->z,a->n);
1927 mpz_mul(
y,a->z,
b->n);
1931 mpz_mul(a->n,a->n,
b->n);
1941 mpz_mul(
x,
b->z,a->n);
1942 mpz_add(a->z,a->z,
x);
1961 mpz_mul(
x,a->z,
b->n);
1962 mpz_add(a->z,
b->z,
x);
1964 mpz_init_set(a->n,
b->n);
1972 mpz_add(a->z,a->z,
b->z);
◆ _nlMult_aImm_bImm_rNoImm()
number _nlMult_aImm_bImm_rNoImm |
( |
number |
a, |
|
|
number |
b |
|
) |
| |
◆ _nlMult_aNoImm_OR_bNoImm()
number _nlMult_aNoImm_OR_bNoImm |
( |
number |
a, |
|
|
number |
b |
|
) |
| |
Definition at line 2208 of file longrat.cc.
2225 if (u->s==1) u->s=0;
2228 mpz_mul_ui(u->z,
b->z,(
unsigned long)
SR_TO_INT(a));
2240 mpz_mul_ui(u->z,
b->z,(
unsigned long)-
SR_TO_INT(a));
2246 if (mpz_cmp(u->z,
b->n)==0)
2252 mpz_init_set(u->n,
b->n);
2262 mpz_mul(u->z,a->z,
b->z);
2272 if (mpz_cmp(u->z,
b->n)==0)
2278 mpz_init_set(u->n,
b->n);
2286 if (mpz_cmp(u->z,a->n)==0)
2292 mpz_init_set(u->n,a->n);
2298 mpz_mul(u->n,a->n,
b->n);
2299 if (mpz_cmp(u->z,u->n)==0)
◆ _nlNeg_NoImm()
number _nlNeg_NoImm |
( |
number |
a | ) |
|
◆ _nlSub_aNoImm_OR_bNoImm()
number _nlSub_aNoImm_OR_bNoImm |
( |
number |
a, |
|
|
number |
b |
|
) |
| |
Definition at line 1984 of file longrat.cc.
2001 mpz_sub(u->z,
x,
b->z);
2009 if (mpz_cmp(u->z,
b->n)==0)
2015 mpz_init_set(u->n,
b->n);
2048 mpz_sub(u->z,a->z,
x);
2056 if (mpz_cmp(u->z,a->n)==0)
2062 mpz_init_set(u->n,a->n);
2099 mpz_mul(
x,
b->z,a->n);
2100 mpz_mul(
y,a->z,
b->n);
2111 mpz_mul(u->n,a->n,
b->n);
2112 if (mpz_cmp(u->z,u->n)==0)
2127 mpz_mul(
x,
b->z,a->n);
2128 mpz_sub(u->z,a->z,
x);
2136 if (mpz_cmp(u->z,a->n)==0)
2142 mpz_init_set(u->n,a->n);
2159 mpz_mul(
x,a->z,
b->n);
2160 mpz_sub(u->z,
x,
b->z);
2168 if (mpz_cmp(u->z,
b->n)==0)
2174 mpz_init_set(u->n,
b->n);
2181 mpz_sub(u->z,a->z,
b->z);
◆ int_extgcd()
static int int_extgcd |
( |
int |
a, |
|
|
int |
b, |
|
|
int * |
u, |
|
|
int * |
x, |
|
|
int * |
v, |
|
|
int * |
y |
|
) |
| |
|
static |
◆ mpz_mul_si()
void mpz_mul_si |
( |
mpz_ptr |
r, |
|
|
mpz_srcptr |
s, |
|
|
long int |
si |
|
) |
| |
◆ nl_Copy()
◆ nlAdd()
Definition at line 2533 of file longrat.cc.
2538 if ( ((r << 1) >> 1) == r )
2539 return (number)(long)r;
◆ nlBigInt() [1/2]
Definition at line 631 of file longrat.cc.
641 mpz_tdiv_q(tmp->z,
i->z,
i->n);
◆ nlBigInt() [2/2]
number nlBigInt |
( |
number & |
n | ) |
|
◆ nlChineseRemainderSym()
Definition at line 2939 of file longrat.cc.
2946 for(
i=rl-1;
i>=0;
i--)
2948 X[
i]=CF->convSingNFactoryN(
x[
i],
FALSE,CF);
2949 Q[
i]=CF->convSingNFactoryN(q[
i],
FALSE,CF);
2956 number n=CF->convFactoryNSingN(xnew,CF);
2959 number
p=CF->convFactoryNSingN(qnew,CF);
2962 else p2=CF->cfDiv(
p,CF->cfInit(2, CF),CF);
2963 if (CF->cfGreater(n,p2,CF))
2965 number n2=CF->cfSub(n,
p,CF);
2966 CF->cfDelete(&n,CF);
2969 CF->cfDelete(&p2,CF);
2970 CF->cfDelete(&
p,CF);
2972 CF->cfNormalize(n,CF);
◆ nlClearContent()
Definition at line 2983 of file longrat.cc.
2987 numberCollectionEnumerator.
Reset();
2989 if( !numberCollectionEnumerator.
MoveNext() )
3004 int normalcount = 0;
3007 number& n = numberCollectionEnumerator.
Current();
3019 }
while (numberCollectionEnumerator.
MoveNext() );
3026 numberCollectionEnumerator.
Reset();
3028 while (numberCollectionEnumerator.
MoveNext() )
3030 number& n = numberCollectionEnumerator.
Current();
3032 if( (--normalcount) <= 0)
3046 numberCollectionEnumerator.
Reset();
3048 while (numberCollectionEnumerator.
MoveNext() )
3050 number& nn = numberCollectionEnumerator.
Current();
3063 numberCollectionEnumerator.
Reset();
3065 while (numberCollectionEnumerator.
MoveNext() )
3067 number& n = numberCollectionEnumerator.
Current();
◆ nlClearDenominators()
Definition at line 3074 of file longrat.cc.
3078 numberCollectionEnumerator.
Reset();
3080 if( !numberCollectionEnumerator.
MoveNext() )
3103 number& cand1 = numberCollectionEnumerator.
Current();
3113 mpz_init_set(
cand->z, cand1->n);
3118 mpz_lcm(
cand->z,
cand->z, cand1->n);
3123 while (numberCollectionEnumerator.
MoveNext() );
3138 numberCollectionEnumerator.
Reset();
3139 while (numberCollectionEnumerator.
MoveNext() )
3141 number& n = numberCollectionEnumerator.
Current();
3153 numberCollectionEnumerator.
Reset();
3160 while (numberCollectionEnumerator.
MoveNext() )
3162 number &n = numberCollectionEnumerator.
Current();
◆ nlCoeffIsEqual()
◆ nlCoeffName()
Definition at line 3168 of file longrat.cc.
3170 if (r->cfDiv==
nlDiv)
return (
char*)
"QQ";
3171 else return (
char*)
"ZZ";
◆ nlCoeffString()
◆ nlCoeffWrite()
◆ nlConvFactoryNSingN()
◆ nlConvSingNFactoryN()
Definition at line 332 of file longrat.cc.
347 long lz=mpz_get_si(n->z);
348 if (mpz_cmp_si(n->z,lz)==0)
term=lz;
351 mpz_init_set( dummy,n->z );
360 mpz_init_set(
num, n->z );
361 mpz_init_set(
den, n->n );
◆ nlCopy()
◆ nlCopyMap()
number nlCopyMap |
( |
number |
a, |
|
|
const |
coeffs, |
|
|
const |
coeffs |
|
) |
| |
◆ nlDBTest() [1/2]
◆ nlDBTest() [2/2]
Definition at line 240 of file longrat.cc.
244 Print(
"!!longrat: NULL in %s:%d\n",
f,
l);
248 if ((((
long)a)&3L)==3L)
250 Print(
" !!longrat:ptr(3) in %s:%d\n",
f,
l);
253 if ((((
long)a)&3L)==1L)
255 if (((((
LONG)(
long)a)<<1)>>1)!=((
LONG)(
long)a))
257 Print(
" !!longrat:arith:%lx in %s:%d\n",(
long)a,
f,
l);
267 if (a->debug!=123456)
269 Print(
"!!longrat:debug:%d in %s:%d\n",a->debug,
f,
l);
273 if ((a->s<0)||(a->s>4))
275 Print(
"!!longrat:s=%d in %s:%d\n",a->s,
f,
l);
283 if (a->z[0]._mp_alloc==0)
284 Print(
"!!longrat:z->alloc=0 in %s:%d\n",
f,
l);
288 if ((a->n[0]._mp_d[0]==0)&&(a->n[0]._mp_alloc<=1))
290 Print(
"!!longrat: n==0 in %s:%d\n",
f,
l);
298 if (a->z[0]._mp_alloc==0)
299 Print(
"!!longrat:n->alloc=0 in %s:%d\n",
f,
l);
300 if ((
mpz_size1(a->n) ==1) && (mpz_cmp_si(a->n,1L)==0))
302 Print(
"!!longrat:integer as rational in %s:%d\n",
f,
l);
303 mpz_clear(a->n); a->s=3;
308 Print(
"!!longrat:div. by negative in %s:%d\n",
f,
l);
322 if ((((ui<<3)>>3)==ui)
323 && (mpz_cmp_si(a->z,(
long)ui)==0))
325 Print(
"!!longrat:im int %d in %s:%d\n",ui,
f,
l);
◆ nlDelete()
◆ nlDiv()
Definition at line 1003 of file longrat.cc.
1016 if (
j==1L)
return a;
1031 mpz_init_set_si(u->z,(
long)
i);
1032 mpz_init_set_si(u->n,(
long)
j);
1055 if (mpz_cmp(u->z,
b->z)==0)
1061 mpz_init_set(u->n,
b->z);
1070 mpz_init_set(u->n,a->n);
1090 mpz_init_set(u->n,
b->z);
1091 if (a->s<2) mpz_mul(u->n,u->n,a->n);
1092 if (
b->s<2) mpz_mul(u->z,u->z,
b->n);
1100 if (mpz_cmp_si(u->n,1L)==0)
◆ nlDivBy()
Definition at line 938 of file longrat.cc.
946 return (mpz_divisible_ui_p(a->z,
SR_TO_INT(
b))!=0);
949 return mpz_divisible_p(a->z,
b->z) != 0;
◆ nlDivComp()
◆ nlEqual()
◆ nlExactDiv()
number nlExactDiv |
( |
number |
a, |
|
|
number |
b, |
|
|
const coeffs |
r |
|
) |
| |
Definition at line 729 of file longrat.cc.
771 mpz_divexact(u->z,a->z,
b->z);
◆ nlExtGcd()
number nlExtGcd |
( |
number |
a, |
|
|
number |
b, |
|
|
number * |
s, |
|
|
number * |
t, |
|
|
const |
coeffs |
|
) |
| |
Definition at line 2881 of file longrat.cc.
2885 mpz_init((*s)->z); (*s)->s=3;
2887 mpz_init((*t)->z); (*t)->s=3;
2889 mpz_init(
g->z);
g->s=3;
2897 aa=(mpz_ptr)
omAlloc(
sizeof(mpz_t));
2906 bb=(mpz_ptr)
omAlloc(
sizeof(mpz_t));
2913 mpz_gcdext(
g->z,(*s)->z,(*t)->z,aa,bb);
◆ nlFarey()
number nlFarey |
( |
number |
nN, |
|
|
number |
nP, |
|
|
const coeffs |
CF |
|
) |
| |
Definition at line 2810 of file longrat.cc.
2812 mpz_t
A,
B,C,
D,
E,
N,P,tmp;
2814 else mpz_init_set(P,nP->z);
2815 const mp_bitcnt_t bits=2*(
mpz_size1(P)+1)*GMP_LIMB_BITS;
2818 else mpz_set(
N,nN->z);
2821 mpz_init2(
A,bits); mpz_set_ui(
A,0L);
2822 mpz_init2(
B,bits); mpz_set_ui(
B,1L);
2823 mpz_init2(C,bits); mpz_set_ui(C,0L);
2825 mpz_init2(
E,bits); mpz_set(
E,P);
2826 mpz_init2(tmp,bits);
2831 mpz_add(tmp,tmp,tmp);
2832 if (mpz_cmp(tmp,P)<0)
2841 if (mpz_cmp_ui(tmp,1)==0)
2848 mpz_init_set(z->z,
N);
2849 mpz_init_set(z->n,
B);
2862 mpz_divmod(tmp,
D,
E,
N);
◆ nlGcd()
Definition at line 1203 of file longrat.cc.
1221 if((
i==0L)||(
j==0L))
1244 unsigned long t=mpz_gcd_ui(
NULL,
b->z,(
long)aa);
1254 unsigned long t=mpz_gcd_ui(
NULL,a->z,(
long)bb);
◆ nlGetDenom()
Definition at line 1499 of file longrat.cc.
1516 mpz_init_set(u->z,n->n);
◆ nlGetNumerator()
Definition at line 1528 of file longrat.cc.
1543 mpz_init_set(u->z,n->z);
◆ nlGetUnit()
◆ nlGMP()
Definition at line 1478 of file longrat.cc.
1490 WarnS(
"Omitted denominator during coefficient mapping !");
◆ nlGreater()
◆ nlGreaterZero()
◆ nlInit()
Definition at line 2438 of file longrat.cc.
2441 #if MAX_NUM_SIZE == 60
2446 if ( ((((
long)ii)==
i) && ((ii << 3) >> 3) == ii )) n=
INT_TO_SR(ii);
◆ nlInit2()
create a rational i/j (implicitly) over Q NOTE: make sure to use correct Q in debug mode
Definition at line 2376 of file longrat.cc.
2382 mpz_init_set_si(z->z,(
long)
i);
2383 mpz_init_set_si(z->n,(
long)
j);
◆ nlInit2gmp()
create a rational i/j (implicitly) over Q NOTE: make sure to use correct Q in debug mode
Definition at line 2389 of file longrat.cc.
2395 mpz_init_set(z->z,
i);
2396 mpz_init_set(z->n,
j);
◆ nlInitChar()
◆ nlInitMPZ()
static number nlInitMPZ |
( |
mpz_t |
m, |
|
|
const |
coeffs |
|
) |
| |
|
static |
◆ nlInpAdd()
Definition at line 2551 of file longrat.cc.
2557 if ( ((r << 1) >> 1) == r )
◆ nlInpGcd()
◆ nlInpIntDiv()
void nlInpIntDiv |
( |
number & |
a, |
|
|
number |
b, |
|
|
const coeffs |
r |
|
) |
| |
Definition at line 2792 of file longrat.cc.
2804 else mpz_sub(a->z,a->z,rr->z);
2805 mpz_divexact(a->z,a->z,
b->z);
◆ nlInpMult()
Definition at line 2617 of file longrat.cc.
2628 mpz_mul(aa->z,a->z,
b->z);
2633 mpz_init_set(a->n,
b->n);
2641 mpz_mul(a->n,a->n,
b->n);
◆ nlInt()
Definition at line 599 of file longrat.cc.
610 long ul=mpz_get_si(
i->z);
611 if (mpz_cmp_si(
i->z,ul)!=0)
return 0;
617 mpz_tdiv_q(tmp,
i->z,
i->n);
622 if (mpz_cmp_si(tmp,ul)!=0) ul=0;
◆ nlIntDiv()
Definition at line 796 of file longrat.cc.
816 if (rr<0) rr+=
ABS(bb);
846 mpz_init_set(u->z,a->z);
851 else mpz_sub(u->z,u->z,rr->z);
852 mpz_divexact(u->z,u->z,
b->z);
◆ nlIntMod()
Definition at line 877 of file longrat.cc.
899 mpz_init_set_si(aa, ai);
906 mpz_mod(u->z, aa,
b->z);
924 mpz_mod(u->z, a->z,
b->z);
◆ nlInvers()
Definition at line 649 of file longrat.cc.
671 mpz_init_set_ui(n->z,1L);
672 mpz_init_set_si(n->n,(
long)
SR_TO_INT(a));
676 mpz_init_set_si(n->z,-1L);
677 mpz_init_set_si(n->n,(
long)-
SR_TO_INT(a));
687 mpz_init_set(n->n,a->z);
693 mpz_init_set(n->z,a->n);
699 if (mpz_cmp_ui(n->n,1L)==0)
712 mpz_init_set_si(n->z,-1L);
716 mpz_init_set_ui(n->z,1L);
◆ nlIsMOne()
◆ nlIsOne()
◆ nlIsUnit()
◆ nlIsZero()
Definition at line 2465 of file longrat.cc.
2470 if (mpz_cmp_si(a->z,0L)==0)
2472 printf(
"gmp-0 in nlIsZero\n");
◆ nlLcm()
static number nlLcm |
( |
number |
a, |
|
|
number |
b, |
|
|
const coeffs |
r |
|
) |
| |
|
static |
◆ nlMapGMP()
Definition at line 201 of file longrat.cc.
207 mpz_init_set(z->z,(mpz_ptr) from);
◆ nlMapLongR()
Definition at line 427 of file longrat.cc.
439 size = (*f)[0]._mp_size;
457 e=(*f)[0]._mp_exp-
size;
464 void* (*allocfunc) (size_t);
465 mp_get_memory_functions (&allocfunc,
NULL,
NULL);
468 al = dest->_mp_size =
size;
470 dd = (mp_ptr)allocfunc(
sizeof(mp_limb_t)*al);
473 nn = (mp_ptr)allocfunc(
sizeof(mp_limb_t)*bl);
477 ndest->_mp_alloc = ndest->_mp_size = bl;
482 al = dest->_mp_size =
size+e;
484 dd = (mp_ptr)allocfunc(
sizeof(mp_limb_t)*al);
486 for (
i=0;
i<e;
i++) dd[
i] = 0;
491 dest->_mp_alloc = al;
◆ nlMapMachineInt()
number nlMapMachineInt |
( |
number |
from, |
|
|
const |
coeffs, |
|
|
const |
coeffs |
|
) |
| |
Definition at line 225 of file longrat.cc.
231 mpz_init_set_ui(z->z,(
unsigned long) from);
◆ nlMapP()
◆ nlMapR()
Definition at line 397 of file longrat.cc.
411 mpz_init_set_ui(h1,1);
412 while((FLT_RADIX*
f) < DBL_MAX &&
i<DBL_MANT_DIG)
415 mpz_mul_ui(h1,h1,FLT_RADIX);
420 memcpy(&(re->n),&h1,
sizeof(h1));
422 if(f_sign==-1) re=
nlNeg(re,dst);
◆ nlMapZ()
◆ nlModP()
Definition at line 1436 of file longrat.cc.
1452 const unsigned long PP =
p;
1455 number z =
n_Init(
static_cast<long>(mpz_fdiv_ui(q->z, PP)), Zp );
1461 number n =
n_Init(
static_cast<long>(mpz_fdiv_ui(q->n, PP)), Zp );
◆ nlMPZ()
static void nlMPZ |
( |
mpz_t |
m, |
|
|
number & |
n, |
|
|
const coeffs |
r |
|
) |
| |
|
static |
Definition at line 2651 of file longrat.cc.
2656 else mpz_init_set(
m, (mpz_ptr)n->z);
◆ nlMult()
◆ nlNeg()
◆ nlNormalize()
Definition at line 1345 of file longrat.cc.
1357 if (mpz_cmp_si(
x->n,1L)==0)
1367 mpz_gcd(
gcd,
x->z,
x->n);
1369 if (mpz_cmp_si(
gcd,1L)!=0)
1371 mpz_divexact(
x->z,
x->z,
gcd);
1372 mpz_divexact(
x->n,
x->n,
gcd);
1373 if (mpz_cmp_si(
x->n,1L)==0)
◆ nlNormalize_Gcd()
static void nlNormalize_Gcd |
( |
number & |
x | ) |
|
|
static |
Definition at line 1663 of file longrat.cc.
1667 mpz_gcd(
gcd,
x->z,
x->n);
1669 if (mpz_cmp_si(
gcd,1L)!=0)
1671 mpz_divexact(
x->z,
x->z,
gcd);
1672 mpz_divexact(
x->n,
x->n,
gcd);
1673 if (mpz_cmp_si(
x->n,1L)==0)
◆ nlNormalizeHelper()
number nlNormalizeHelper |
( |
number |
a, |
|
|
number |
b, |
|
|
const coeffs |
r |
|
) |
| |
Definition at line 1389 of file longrat.cc.
1411 mpz_gcd(
gcd,a->z,
b->n);
1412 if (mpz_cmp_si(
gcd,1L)!=0)
1416 mpz_divexact(bt,
b->n,
gcd);
1420 mpz_mul(
result->z,bt,a->z);
◆ nlPower()
void nlPower |
( |
number |
x, |
|
|
int |
exp, |
|
|
number * |
lu, |
|
|
const coeffs |
r |
|
) |
| |
Definition at line 1113 of file longrat.cc.
1134 mpz_pow_ui((*u)->z,
x->z,(
unsigned long)
exp);
1137 if (mpz_cmp_si(
x->n,1L)==0)
1145 mpz_pow_ui((*u)->n,
x->n,(
unsigned long)
exp);
◆ nlQuot1()
Definition at line 969 of file longrat.cc.
971 long ch = r->cfInt(c, r);
982 mpz_init_set_ui(dummy, ch);
985 info.exp = (
unsigned long) 1;
◆ nlQuotRem()
number nlQuotRem |
( |
number |
a, |
|
|
number |
b, |
|
|
number * |
r, |
|
|
const coeffs |
R |
|
) |
| |
Definition at line 2724 of file longrat.cc.
2753 rr = mpz_divmod_ui(qq, rrr, a->z, (
unsigned long)
ABS(
SR_TO_INT(
b)));
2767 mpz_divmod(qq, rr, a->z,
b->z);
◆ nlRandom()
◆ nlRead()
Definition at line 32 of file longrat0.cc.
55 if (mpz_cmp_si(n,0L)==0)
61 else if (mpz_cmp_si(n,1L)==0)
67 if (mpz_cmp_si(z,0L)==0)
◆ nlReadFd()
Definition at line 3227 of file longrat.cc.
3249 #if SIZEOF_LONG == 8
3278 #if SIZEOF_LONG == 8
3284 default:
Werror(
"error in reading number: invalid subtype %d",sub_type);
◆ nlRInit()
◆ nlSetMap()
◆ nlShort1()
number nlShort1 |
( |
number |
x | ) |
|
◆ nlShort3()
static number nlShort3 |
( |
number |
x | ) |
|
|
inlinestatic |
Definition at line 115 of file longrat.cc.
126 LONG ui=mpz_get_si(
x->z);
127 if ((((ui<<3)>>3)==ui)
128 && (mpz_cmp_si(
x->z,(
long)ui)==0))
◆ nlShort3_noinline()
number nlShort3_noinline |
( |
number |
x | ) |
|
◆ nlSize()
int nlSize |
( |
number |
a, |
|
|
const |
coeffs |
|
) |
| |
Definition at line 570 of file longrat.cc.
576 int s=a->z[0]._mp_alloc;
585 int d=a->n[0]._mp_alloc;
◆ nlSub()
Definition at line 2599 of file longrat.cc.
2604 if ( ((r << 1) >> 1) == r )
2606 return (number)(long)r;
◆ nlWrite()
Definition at line 91 of file longrat0.cc.
104 int l=mpz_sizeinbase(a->z,10);
105 if (a->s<2)
l=
si_max(
l,(
int)mpz_sizeinbase(a->n,10));
108 z=mpz_get_str(
s,10,a->z);
113 z=mpz_get_str(
s,10,a->n);
◆ nlWriteFd()
Definition at line 3181 of file longrat.cc.
3185 #if SIZEOF_LONG == 4
3192 fprintf(d->
f_write,
"4 %d ",nnn);
3197 mpz_init_set_si(tmp,nn);
3208 fprintf(d->
f_write,
"%d ",n->s+5);
◆ nlXExtGcd()
number nlXExtGcd |
( |
number |
a, |
|
|
number |
b, |
|
|
number * |
s, |
|
|
number * |
t, |
|
|
number * |
u, |
|
|
number * |
v, |
|
|
const coeffs |
r |
|
) |
| |
Definition at line 2672 of file longrat.cc.
2693 mpz_init_set(aa, a->z);
2701 mpz_init_set(bb,
b->z);
2703 mpz_t erg; mpz_t bs; mpz_t bt;
2708 mpz_gcdext(erg, bs, bt, aa, bb);
2710 mpz_div(aa, aa, erg);
◆ n_SwitchChinRem
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
static number nlLcm(number a, number b, const coeffs r)
@ n_rep_gap_rat
(number), see longrat.h
@ n_rep_gmp
(mpz_ptr), see rmodulon,h
#define omCheckAddrSize(addr, size)
@ n_Zn
only used if HAVE_RINGS is defined
BOOLEAN nlIsUnit(number a, const coeffs)
LINLINE BOOLEAN nlIsZero(number za, const coeffs r)
static const int SW_RATIONAL
set to 1 for computations over Q
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
void StringAppendS(const char *st)
coeffs nlQuot1(number c, const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_R(const coeffs r)
virtual reference Current()=0
Gets the current element in the collection (read and write).
LINLINE void nlInpMult(number &a, number b, const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_2toM(const coeffs r)
nMapFunc nlSetMap(const coeffs src, const coeffs dst)
long nlInt(number &n, const coeffs r)
const CanonicalForm int const CFList const Variable & y
number nlMapZ(number from, const coeffs src, const coeffs dst)
number nlExtGcd(number a, number b, number *s, number *t, const coeffs)
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
LINLINE BOOLEAN nlIsOne(number a, const coeffs r)
number nlChineseRemainderSym(number *x, number *q, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs CF)
LINLINE number nlCopy(number a, const coeffs r)
number _nlMult_aNoImm_OR_bNoImm(number a, number b)
BOOLEAN nlIsMOne(number a, const coeffs r)
char * nlCoeffName(const coeffs r)
void nlCoeffWrite(const coeffs r, BOOLEAN details)
void _nlDelete_NoImm(number *a)
static number nlMapR(number from, const coeffs src, const coeffs dst)
@ n_rep_float
(float), see shortfl.h
int nlDivComp(number a, number b, const coeffs r)
SI_FLOAT nrFloat(number n)
Converts a n_R number into a float. Needed by Maps.
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
REvaluation E(1, terms.length(), IntRandom(25))
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
@ n_Q
rational (GMP) numbers
BOOLEAN nlDivBy(number a, number b, const coeffs)
number nlMapMachineInt(number from, const coeffs, const coeffs)
CanonicalForm make_cf(const mpz_ptr n)
number nlShort1(number x)
const CanonicalForm CFMap CFMap & N
@ n_rep_int
(int), see modulop.h
LINLINE void nlInpAdd(number &a, number b, const coeffs r)
number _nlSub_aNoImm_OR_bNoImm(number a, number b)
LINLINE number nlInit(long i, const coeffs r)
LINLINE number nlSub(number la, number li, const coeffs r)
void s_readmpz(s_buff F, mpz_t a)
BOOLEAN nlDBTest(number a, const char *f, const int l)
@ n_long_R
real floating point (GMP) numbers
virtual void Reset()=0
Sets the enumerator to its initial position: -1, which is before the first element in the collection.
int nlSize(number a, const coeffs)
LINLINE BOOLEAN nlEqual(number a, number b, const coeffs r)
static number nlRandom(siRandProc p, number v2, number, const coeffs cf)
void nlPower(number x, int exp, number *lu, const coeffs r)
static void nlClearContent(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
static int int_extgcd(int a, int b, int *u, int *x, int *v, int *y)
const char *const nDivBy0
void PrintS(const char *s)
#define omFreeSize(addr, size)
void nlWriteFd(number n, const ssiInfo *d, const coeffs)
static void nlClearDenominators(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
void nlWrite(number a, const coeffs r)
number nlXExtGcd(number a, number b, number *s, number *t, number *u, number *v, const coeffs r)
number nlGetUnit(number n, const coeffs cf)
number nlNormalizeHelper(number a, number b, const coeffs r)
static number nlConvFactoryNSingN(const CanonicalForm f, const coeffs r)
static void nlNormalize_Gcd(number &x)
char * nEatLong(char *s, mpz_ptr i)
extracts a long integer from s, returns the rest
static void nlMPZ(mpz_t m, number &n, const coeffs r)
number nlGcd(number a, number b, const coeffs r)
static CanonicalForm nlConvSingNFactoryN(number n, const BOOLEAN setChar, const coeffs)
static number nlInitMPZ(mpz_t m, const coeffs)
void nlNormalize(number &x, const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
void chineseRemainderCached(CFArray &a, CFArray &n, CanonicalForm &xnew, CanonicalForm &prod, CFArray &inv)
number nlGetNumerator(number &n, const coeffs r)
void 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,...
number nlGetDenom(number &n, const coeffs r)
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
long s_readlong(s_buff F)
number nlQuotRem(number a, number b, number *r, const coeffs R)
BOOLEAN nlGreaterZero(number za, const coeffs r)
BOOLEAN _nlEqual_aNoImm_OR_bNoImm(number a, number b)
number nlIntMod(number a, number b, const coeffs r)
number nlMapGMP(number from, const coeffs src, const coeffs dst)
number _nlMult_aImm_bImm_rNoImm(number a, number b)
@ n_R
single prescision (6,6) real numbers
gmp_float exp(const gmp_float &a)
long npInt(number &n, const coeffs r)
const CanonicalForm const CanonicalForm const CanonicalForm const CanonicalForm & cand
void nlInpGcd(number &a, number b, const coeffs r)
void mpz_mul_si(mpz_ptr r, mpz_srcptr s, long int si)
number nlDiv(number a, number b, const coeffs r)
virtual bool MoveNext()=0
Advances the enumerator to the next element of the collection. returns true if the enumerator was suc...
number _nlCopy_NoImm(number a)
static int si_max(const int a, const int b)
@ n_rep_gmp_float
(gmp_float), see
LINLINE number nlAdd(number la, number li, const coeffs r)
void Werror(const char *fmt,...)
number nlInvers(number a, const coeffs r)
void WerrorS(const char *s)
static number nlShort3(number x)
number nlFarey(number nN, number nP, const coeffs CF)
#define omCheckIf(cond, test)
const char * nlRead(const char *s, number *a, const coeffs r)
static number nlMapP(number from, const coeffs src, const coeffs dst)
void _nlInpAdd_aNoImm_OR_bNoImm(number &a, number b)
number nlIntDiv(number a, number b, const coeffs r)
void gmp_denominator(const CanonicalForm &f, mpz_ptr result)
void gmp_numerator(const CanonicalForm &f, mpz_ptr result)
number nlShort3_noinline(number x)
const Variable & v
< [in] a sqrfree bivariate poly
LINLINE number nlMult(number a, number b, const coeffs r)
LINLINE number nlNeg(number za, const coeffs r)
const CanonicalForm int s
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...
void s_readmpz_base(s_buff F, mpz_ptr a, int base)
LINLINE void nlDelete(number *a, const coeffs r)
static number nlMapLongR(number from, const coeffs src, const coeffs dst)
number _nlNeg_NoImm(number a)
const ExtensionInfo & info
< [in] sqrfree poly
number nlExactDiv(number a, number b, const coeffs r)
BOOLEAN nlCoeffIsEqual(const coeffs r, n_coeffType n, void *p)
#define GCD_NORM_COND(OLD, NEW)
BOOLEAN nlGreater(number a, number b, const coeffs r)
number nlReadFd(const ssiInfo *d, const coeffs)
static char * nlCoeffString(const coeffs r)
number _nlAdd_aNoImm_OR_bNoImm(number a, number b)
@ n_rep_gap_gmp
(), see rinteger.h, new impl.