11 #include <factory/factory.h> 23 #if defined(DO_LINLINE) && defined(P_NUMBERS_H) && !defined(LDEBUG) 24 #define LINLINE static FORCE_INLINE 88 #define nlTest(a, r) nlDBTest(a,__FILE__,__LINE__, r) 91 #define nlTest(a, r) do {} while (0) 98 #define MAX_NUM_SIZE 60 99 #define POW_2_28 (1L<<60) 100 #define POW_2_28_32 (1L<<28) 103 #define MAX_NUM_SIZE 28 104 #define POW_2_28 (1L<<28) 105 #define POW_2_28_32 (1L<<28) 113 if (mpz_cmp_ui(x->z,0L)==0)
121 LONG ui=mpz_get_si(x->z);
122 if ((((ui<<3)>>3)==ui)
123 && (mpz_cmp_si(x->z,(
long)ui)==0))
146 #ifndef BYTES_PER_MP_LIMB 147 #define BYTES_PER_MP_LIMB sizeof(mp_limb_t) 157 #define mpz_isNeg(A) ((A)->_mp_size<0) 158 #define mpz_limb_size(A) ((A)->_mp_size) 159 #define mpz_limb_d(A) ((A)->_mp_d) 176 #if (__GNU_MP_VERSION*10+__GNU_MP_VERSION_MINOR < 31) 212 mpz_init_set(z->z,(mpz_ptr) from);
237 mpz_init_set_ui(z->z,(
unsigned long) from);
250 Print(
"!!longrat: NULL in %s:%d\n",f,l);
254 if ((((
long)a)&3L)==3L)
256 Print(
" !!longrat:ptr(3) in %s:%d\n",f,l);
259 if ((((
long)a)&3L)==1L)
261 if (((((
LONG)(
long)a)<<1)>>1)!=((
LONG)(
long)a))
263 Print(
" !!longrat:arith:%lx in %s:%d\n",(
long)a, f,l);
273 if (a->debug!=123456)
275 Print(
"!!longrat:debug:%d in %s:%d\n",a->debug,f,l);
279 if ((a->s<0)||(a->s>4))
281 Print(
"!!longrat:s=%d in %s:%d\n",a->s,f,l);
289 if (a->z[0]._mp_alloc==0)
290 Print(
"!!longrat:z->alloc=0 in %s:%d\n",f,l);
294 if ((a->n[0]._mp_d[0]==0)&&(a->n[0]._mp_alloc<=1))
296 Print(
"!!longrat: n==0 in %s:%d\n",f,l);
304 if (a->z[0]._mp_alloc==0)
305 Print(
"!!longrat:n->alloc=0 in %s:%d\n",f,l);
306 if ((
mpz_size1(a->n) ==1) && (mpz_cmp_si(a->n,1L)==0))
308 Print(
"!!longrat:integer as rational in %s:%d\n",f,l);
309 mpz_clear(a->n); a->s=3;
314 Print(
"!!longrat:div. by negative in %s:%d\n",f,l);
328 if ((((ui<<3)>>3)==ui)
329 && (mpz_cmp_si(a->z,(
long)ui)==0))
331 Print(
"!!longrat:im int %d in %s:%d\n",ui,f,l);
353 long lz=mpz_get_si(n->z);
354 if (mpz_cmp_si(n->z,lz)==0) term=lz;
357 mpz_init_set( dummy,n->z );
366 mpz_init_set( num, n->z );
367 mpz_init_set( den, n->n );
368 term =
make_cf( num, den, ( n->s != 1 ));
417 mpz_init_set_ui(h1,1);
418 while((FLT_RADIX*f) < DBL_MAX && i<DBL_MANT_DIG)
421 mpz_mul_ui(h1,h1,FLT_RADIX);
426 memcpy(&(re->n),&h1,
sizeof(h1));
428 if(f_sign==-1) re=
nlNeg(re,dst);
445 size = (*f)[0]._mp_size;
463 e=(*f)[0]._mp_exp-
size;
470 void* (*allocfunc) (size_t);
471 mp_get_memory_functions (&allocfunc,
NULL,
NULL);
474 al = dest->_mp_size =
size;
476 dd = (mp_ptr)allocfunc(
sizeof(mp_limb_t)*al);
477 for (i=0;i<
size;i++) dd[i] = qp[i];
479 nn = (mp_ptr)allocfunc(
sizeof(mp_limb_t)*bl);
483 ndest->_mp_alloc = ndest->_mp_size = bl;
488 al = dest->_mp_size = size+e;
490 dd = (mp_ptr)allocfunc(
sizeof(mp_limb_t)*al);
491 for (i=0;i<
size;i++) dd[i+e] = qp[i];
492 for (i=0;i<e;i++) dd[i] = 0;
497 dest->_mp_alloc = al;
498 if (negative) mpz_neg(dest,dest);
582 int s=a->z[0]._mp_alloc;
591 int d=a->n[0]._mp_alloc;
616 long ul=mpz_get_si(i->z);
617 if (mpz_cmp_si(i->z,ul)!=0)
return 0;
623 mpz_tdiv_q(tmp,i->z,i->n);
628 if (mpz_cmp_si(tmp,ul)!=0) ul=0;
647 mpz_tdiv_q(tmp->z,i->z,i->n);
677 mpz_init_set_si(n->z,1L);
678 mpz_init_set_si(n->n,(
long)
SR_TO_INT(a));
682 mpz_init_set_si(n->z,-1L);
683 mpz_init_set_si(n->n,(
long)-
SR_TO_INT(a));
693 mpz_init_set(n->n,a->z);
699 mpz_init_set(n->z,a->n);
705 if (mpz_cmp_ui(n->n,1L)==0)
718 mpz_init_set_si(n->z,-1L);
722 mpz_init_set_si(n->z,1L);
769 mpz_divexact(u->z,a->z,b->z);
806 if (rr<0) rr+=
ABS(bb);
836 mpz_init_set(u->z,a->z);
841 else mpz_sub(u->z,u->z,rr->z);
842 mpz_divexact(u->z,u->z,b->z);
889 mpz_init_set_si(aa, ai);
896 mpz_mod(u->z, aa, b->z);
914 mpz_mod(u->z, a->z, b->z);
936 return (mpz_divisible_ui_p(a->z,
SR_TO_INT(b))!=0);
939 return mpz_divisible_p(a->z, b->z) != 0;
946 if (
nlDivBy(b, a, r))
return 2;
949 if (
nlDivBy(b, a, r))
return 1;
960 long ch = r->cfInt(c, r);
971 dummy = (mpz_ptr)
omAlloc(
sizeof(mpz_t));
972 mpz_init_set_ui(dummy, ch);
975 info.
exp = (
unsigned long) 1;
1005 if (j==1L)
return a;
1020 mpz_init_set_si(u->z,(
long)i);
1021 mpz_init_set_si(u->n,(
long)j);
1044 if (mpz_cmp(u->z,b->z)==0)
1050 mpz_init_set(u->n,b->z);
1053 else if (
SR_HDL(b) & SR_INT)
1059 mpz_init_set(u->n,a->n);
1079 mpz_init_set(u->n,b->z);
1080 if (a->s<2) mpz_mul(u->n,u->n,a->n);
1081 if (b->s<2) mpz_mul(u->z,u->z,b->n);
1089 if (mpz_cmp_si(u->n,1L)==0)
1123 mpz_pow_ui((*u)->z,x->z,(
unsigned long)exp);
1126 if (mpz_cmp_si(x->n,1L)==0)
1134 mpz_pow_ui((*u)->n,x->n,(
unsigned long)exp);
1146 if (exp<0)
Print(
"nlPower: neg. exp. %d\n",exp);
1210 if((i==0L)||(j==0L))
1228 if (((!(
SR_HDL(a) & SR_INT))&&(a->s<2))
1233 unsigned long t=mpz_gcd_ui(
NULL,b->z,(
long)aa);
1243 unsigned long t=mpz_gcd_ui(
NULL,a->z,(
long)bb);
1254 result->debug=123456;
1256 mpz_init(result->z);
1257 mpz_gcd(result->z,a->z,b->z);
1316 if (mpz_cmp_ui(x->z,0L)==0)
1323 if (mpz_cmp(x->z,x->n)==0)
1346 if (mpz_cmp_si(x->n,1L)==0)
1356 mpz_gcd(gcd,x->z,x->n);
1358 if (mpz_cmp_si(gcd,1L)!=0)
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)
1391 result->debug=123456;
1396 mpz_init(result->z);
1400 mpz_gcd(gcd,a->z,b->n);
1401 if (mpz_cmp_si(gcd,1L)!=0)
1404 mpz_init_set(bt,b->n);
1405 mpz_divexact(bt,bt,gcd);
1409 mpz_mul(result->z,bt,a->z);
1416 mpz_mul(result->z,b->n,a->z);
1441 const unsigned long PP =
p;
1444 number
z =
n_Init( static_cast<long>(mpz_fdiv_ui(q->z, PP)), Zp );
1450 number
n =
n_Init( static_cast<long>(mpz_fdiv_ui(q->n, PP)), Zp );
1479 WarnS(
"Omitted denominator during coefficient mapping !");
1481 mpz_set((mpz_ptr) n, i->z);
1496 if (!(
SR_HDL(n) & SR_INT))
1505 mpz_init_set(u->z,n->n);
1525 if (!(
SR_HDL(n) & SR_INT))
1532 mpz_init_set(u->z,n->z);
1555 if (a->s!=0)
return FALSE;
1556 number
n=
b; b=
a; a=
n;
1563 if ((((
long)a) > 0L) && (
mpz_isNeg(b->z)))
1565 if ((((
long)a) < 0L) && (!
mpz_isNeg(b->z)))
1568 mpz_init_set(bb,b->n);
1570 bo=(mpz_cmp(bb,b->z)==0);
1575 if (((a->s==1) && (b->s==3))
1576 || ((b->s==1) && (a->s==3)))
1584 mpz_init_set(aa,a->z);
1585 mpz_init_set(bb,b->z);
1586 if (a->s<2) mpz_mul(bb,bb,a->n);
1587 if (b->s<2) mpz_mul(aa,aa,b->n);
1588 bo=(mpz_cmp(aa,bb)==0);
1607 mpz_init_set(b->n,a->n);
1609 mpz_init_set(b->z,a->z);
1647 #define GCD_NORM_COND(OLD,NEW) (mpz_size1(NEW->z)>mpz_size1(OLD->z)) 1653 mpz_gcd(gcd,x->z,x->n);
1655 if (mpz_cmp_si(gcd,1L)!=0)
1657 mpz_divexact(x->z,x->z,gcd);
1658 mpz_divexact(x->n,x->n,gcd);
1659 if (mpz_cmp_si(x->n,1L)==0)
1692 mpz_add(u->z,b->z,x);
1694 if (mpz_cmp_ui(u->z,0L)==0)
1700 if (mpz_cmp(u->z,b->n)==0)
1706 mpz_init_set(u->n,b->n);
1738 mpz_mul(x,b->z,a->n);
1739 mpz_mul(u->z,a->z,b->n);
1740 mpz_add(u->z,u->z,x);
1743 if (mpz_cmp_ui(u->z,0L)==0)
1750 mpz_mul(u->n,a->n,b->n);
1751 if (mpz_cmp(u->z,u->n)==0)
1764 mpz_mul(u->z,b->z,a->n);
1765 mpz_add(u->z,u->z,a->z);
1766 if (mpz_cmp_ui(u->z,0L)==0)
1772 if (mpz_cmp(u->z,a->n)==0)
1778 mpz_init_set(u->n,a->n);
1793 mpz_mul(u->z,a->z,b->n);
1794 mpz_add(u->z,u->z,b->z);
1795 if (mpz_cmp_ui(u->z,0L)==0)
1801 if (mpz_cmp(u->z,b->n)==0)
1807 mpz_init_set(u->n,b->n);
1814 mpz_add(u->z,a->z,b->z);
1839 mpz_add(a->z,a->z,x);
1857 else if (
SR_HDL(a) & SR_INT)
1873 mpz_add(u->z,b->z,x);
1876 mpz_init_set(u->n,b->n);
1912 mpz_mul(x,b->z,a->n);
1913 mpz_mul(y,a->z,b->n);
1917 mpz_mul(a->n,a->n,b->n);
1927 mpz_mul(x,b->z,a->n);
1928 mpz_add(a->z,a->z,x);
1947 mpz_mul(x,a->z,b->n);
1948 mpz_add(a->z,b->z,x);
1950 mpz_init_set(a->n,b->n);
1958 mpz_add(a->z,a->z,b->z);
1987 mpz_sub(u->z,x,b->z);
1989 if (mpz_cmp_ui(u->z,0L)==0)
1995 if (mpz_cmp(u->z,b->n)==0)
2001 mpz_init_set(u->n,b->n);
2024 else if (
SR_HDL(b) & SR_INT)
2034 mpz_sub(u->z,a->z,x);
2036 if (mpz_cmp_ui(u->z,0L)==0)
2042 if (mpz_cmp(u->z,a->n)==0)
2048 mpz_init_set(u->n,a->n);
2085 mpz_mul(x,b->z,a->n);
2086 mpz_mul(y,a->z,b->n);
2090 if (mpz_cmp_ui(u->z,0L)==0)
2097 mpz_mul(u->n,a->n,b->n);
2098 if (mpz_cmp(u->z,u->n)==0)
2113 mpz_mul(x,b->z,a->n);
2114 mpz_sub(u->z,a->z,x);
2116 if (mpz_cmp_ui(u->z,0L)==0)
2122 if (mpz_cmp(u->z,a->n)==0)
2128 mpz_init_set(u->n,a->n);
2145 mpz_mul(x,a->z,b->n);
2146 mpz_sub(u->z,x,b->z);
2148 if (mpz_cmp_ui(u->z,0L)==0)
2154 if (mpz_cmp(u->z,b->n)==0)
2160 mpz_init_set(u->n,b->n);
2167 mpz_sub(u->z,a->z,b->z);
2211 if (u->s==1) u->s=0;
2214 mpz_mul_ui(u->z,b->z,(
unsigned long)
SR_TO_INT(a));
2226 mpz_mul_ui(u->z,b->z,(
unsigned long)-
SR_TO_INT(a));
2232 if (mpz_cmp(u->z,b->n)==0)
2238 mpz_init_set(u->n,b->n);
2248 mpz_mul(u->z,a->z,b->z);
2258 if (mpz_cmp(u->z,b->n)==0)
2264 mpz_init_set(u->n,b->n);
2272 if (mpz_cmp(u->z,a->n)==0)
2278 mpz_init_set(u->n,a->n);
2284 mpz_mul(u->n,a->n,b->n);
2285 if (mpz_cmp(u->z,u->n)==0)
2354 mpz_init_set_si(z->z,i);
2368 mpz_init_set_si(z->z,(
long)i);
2369 mpz_init_set_si(z->n,(
long)j);
2381 mpz_init_set(z->z,i);
2382 mpz_init_set(z->n,j);
2408 #if defined(DO_LINLINE) || !defined(P_NUMBERS_H) 2427 #if MAX_NUM_SIZE == 60 2428 if (((i << 3) >> 3) == i) n=
INT_TO_SR(i);
2432 if ( ((((
long)ii)==i) && ((ii << 3) >> 3) == ii )) n=
INT_TO_SR(ii);
2456 if (mpz_cmp_si(a->z,0L)==0)
2458 printf(
"gmp-0 in nlIsZero\n");
2524 if ( ((r << 1) >> 1) == r )
2525 return (number)(long)r;
2543 if ( ((r << 1) >> 1) == r )
2566 number u=((number) ((r>>1)+
SR_INT));
2567 if (((((LONG)
SR_HDL(u))<<1)>>1)==
SR_HDL(u))
return (u);
2590 if ( ((r << 1) >> 1) == r )
2592 return (number)(long)r;
2614 mpz_mul(aa->z,a->z,b->z);
2619 mpz_init_set(a->n,b->n);
2627 mpz_mul(a->n,a->n,b->n);
2633 #endif // DO_LINLINE 2642 else mpz_init_set(m, (mpz_ptr)n->z);
2653 mpz_init_set(z->z, m);
2679 mpz_init_set(aa, a->z);
2687 mpz_init_set(bb, b->z);
2689 mpz_t erg; mpz_t bs; mpz_t bt;
2694 mpz_gcdext(erg, bs, bt, aa, bb);
2696 mpz_div(aa, aa, erg);
2719 else if (
SR_HDL(a) & SR_INT)
2732 else if (
SR_HDL(b) & SR_INT)
2739 rr = mpz_divmod_ui(qq, rrr, a->z, (
unsigned long)
ABS(
SR_TO_INT(b)));
2753 mpz_divmod(qq, rr, a->z, b->z);
2773 mpz_gcd(a->z,a->z,b->z);
2790 else mpz_sub(a->z,a->z,rr->z);
2791 mpz_divexact(a->z,a->z,b->z);
2798 mpz_t tmp; mpz_init(tmp);
2801 else mpz_init_set(N,nN->z);
2803 else mpz_init_set(P,nP->z);
2806 mpz_init_set_si(A,0L);
2807 mpz_init_set_ui(B,(
unsigned long)1);
2808 mpz_init_set_si(C,0L);
2812 while(mpz_cmp_si(N,0L)!=0)
2815 mpz_add(tmp,tmp,tmp);
2816 if (mpz_cmp(tmp,P)<0)
2825 if (mpz_cmp_ui(tmp,1)==0)
2832 mpz_init_set(z->z,N);
2833 mpz_init_set(z->n,B);
2846 mpz_divmod(tmp,D,E,N);
2869 mpz_init((*s)->z); (*s)->s=3;
2871 mpz_init((*t)->z); (*t)->s=3;
2873 mpz_init(g->z); g->s=3;
2881 aa=(mpz_ptr)
omAlloc(
sizeof(mpz_t));
2890 bb=(mpz_ptr)
omAlloc(
sizeof(mpz_t));
2897 mpz_gcdext(g->z,(*s)->z,(*t)->z,aa,bb);
2917 PrintS(
"// characteristic : 0\n");
2919 PrintS(
"// coeff. ring is : Integers\n");
2930 for(i=rl-1;i>=0;i--)
2932 X[
i]=CF->convSingNFactoryN(x[i],
FALSE,CF);
2933 Q[
i]=CF->convSingNFactoryN(q[i],
FALSE,CF);
2940 number
n=CF->convFactoryNSingN(xnew,CF);
2943 number
p=CF->convFactoryNSingN(qnew,CF);
2947 number n2=
nlSub(n,p,CF);
2967 numberCollectionEnumerator.
Reset();
2969 if( !numberCollectionEnumerator.
MoveNext() )
2984 int normalcount = 0;
2987 number&
n = numberCollectionEnumerator.
Current();
2999 }
while (numberCollectionEnumerator.
MoveNext() );
3006 numberCollectionEnumerator.
Reset();
3008 while (numberCollectionEnumerator.
MoveNext() )
3010 number&
n = numberCollectionEnumerator.
Current();
3012 if( (--normalcount) <= 0)
3026 numberCollectionEnumerator.
Reset();
3028 while (numberCollectionEnumerator.
MoveNext() )
3030 number& nn = numberCollectionEnumerator.
Current();
3040 cand =
nlNeg(cand,cf);
3043 numberCollectionEnumerator.
Reset();
3045 while (numberCollectionEnumerator.
MoveNext() )
3047 number&
n = numberCollectionEnumerator.
Current();
3058 numberCollectionEnumerator.
Reset();
3060 if( !numberCollectionEnumerator.
MoveNext() )
3083 number& cand1 = numberCollectionEnumerator.
Current();
3088 if ((!(
SR_HDL(cand1)&SR_INT))
3093 mpz_init_set(cand->z, cand1->n);
3098 mpz_lcm(cand->z, cand->z, cand1->n);
3103 while (numberCollectionEnumerator.
MoveNext() );
3118 numberCollectionEnumerator.
Reset();
3119 while (numberCollectionEnumerator.
MoveNext() )
3121 number&
n = numberCollectionEnumerator.
Current();
3133 numberCollectionEnumerator.
Reset();
3136 cand =
nlNeg(cand, cf);
3140 while (numberCollectionEnumerator.
MoveNext() )
3142 number &
n = numberCollectionEnumerator.
Current();
3150 if (r->cfDiv==
nlDiv)
return (
char*)
"QQ";
3151 else return (
char*)
"ZZ";
3170 #if SIZEOF_LONG == 4 3177 fprintf(f,
"4 %d ",nnn);
3182 mpz_init_set_si(tmp,nn);
3193 fprintf(f,
"%d ",n->s+5);
3234 #if SIZEOF_LONG == 8 3263 #if SIZEOF_LONG == 8 3269 default:
Werror(
"error in reading number: invalid subtype %d",sub_type);
3302 number c=
nlDiv(a,b,cf);
3333 r->cfSubringGcd =
nlGcd;
3357 r->cfInpNeg =
nlNeg;
3403 r->has_simple_Alloc=
FALSE;
3404 r->has_simple_Inverse=
FALSE;
3411 number nlMod(number
a, number
b)
3433 mpz_mod(r->z,al->z,bl->z);
3438 LONG ui=(int)mpz_get_si(&r->z);
3439 if ((((ui<<3)>>3)==ui)
3440 && (mpz_cmp_si(
x->z,(
long)ui)==0))
3450 #endif // not P_NUMBERS_H 3451 #endif // LONGRAT_CC
LINLINE number nlSub(number la, number li, const coeffs r)
static void nlClearDenominators(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
const CanonicalForm int s
const CanonicalForm int const CFList const Variable & y
void mpz_mul_si(mpz_ptr r, mpz_srcptr s, long int si)
#define omCheckAddrSize(addr, size)
BOOLEAN nlCoeffIsEqual(const coeffs r, n_coeffType n, void *p)
only used if HAVE_RINGS is defined
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
static int int_extgcd(int a, int b, int *u, int *x, int *v, int *y)
char * nlCoeffName(const coeffs r)
long npInt(number &n, const coeffs r)
static number nlConvFactoryNSingN(const CanonicalForm f, const coeffs r)
BOOLEAN nlGreaterZero(number za, const coeffs r)
number nlModP(number q, const coeffs, const coeffs Zp)
static void nlMPZ(mpz_t m, number &n, const coeffs r)
number _nlMult_aNoImm_OR_bNoImm(number a, number b)
number nlShort1(number x)
number nlNormalizeHelper(number a, number b, const coeffs r)
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
LINLINE void nlInpAdd(number &a, number b, const coeffs r)
number nlGetDenom(number &n, const coeffs r)
void nlWrite(number a, const coeffs r)
int nlSize(number a, const coeffs)
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
static FORCE_INLINE BOOLEAN nCoeff_is_R(const coeffs r)
#define omCheckIf(cond, test)
#define omFreeSize(addr, size)
LINLINE number nlAdd(number la, number li, const coeffs r)
void nlInpGcd(number &a, number b, const coeffs r)
BOOLEAN nlIsMOne(number a, const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_2toM(const coeffs r)
(), see rinteger.h, new impl.
void nlCoeffWrite(const coeffs r, BOOLEAN details)
number nlIntDiv(number a, number b, const coeffs r)
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
number nlGcd(number a, number b, const coeffs r)
coeffs nlQuot1(number c, 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 ...
const char * nlRead(const char *s, number *a, const coeffs r)
void WerrorS(const char *s)
void s_readmpz_base(s_buff F, mpz_ptr a, int base)
CanonicalForm make_cf(const mpz_ptr n)
void nlGMP(number &i, number n, const coeffs r)
number nlIntMod(number a, number b, const coeffs r)
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 ...
BOOLEAN nlInitChar(coeffs r, void *p)
BOOLEAN nlGreater(number a, number b, const coeffs r)
LINLINE number nl_Copy(number a, const coeffs r)
static number nlInitMPZ(mpz_t m, const coeffs)
real floating point (GMP) numbers
number nlMapZ(number from, const coeffs src, const coeffs dst)
LINLINE BOOLEAN nlIsOne(number a, const coeffs r)
virtual void Reset()=0
Sets the enumerator to its initial position: -1, which is before the first element in the collection...
single prescision (6,6) real numbers
static number nlLcm(number a, number b, const coeffs r)
static number nlMapP(number from, const coeffs src, const coeffs dst)
LINLINE number nlNeg(number za, const coeffs r)
number nlXExtGcd(number a, number b, number *s, number *t, number *u, number *v, const coeffs r)
float nrFloat(number n)
Converts a n_R number into a float. Needed by Maps.
Coefficient rings, fields and other domains suitable for Singular polynomials.
void s_readmpz(s_buff F, mpz_t a)
const CanonicalForm CFMap CFMap & N
number nlDiv(number a, number b, const coeffs r)
LINLINE number nlMult(number a, number b, const coeffs r)
number nlInvers(number a, const coeffs r)
number _nlCopy_NoImm(number a)
void _nlInpAdd_aNoImm_OR_bNoImm(number &a, number b)
The main handler for Singular numbers which are suitable for Singular polynomials.
Templated enumerator interface for simple iteration over a generic collection of T's.
int nlDivComp(number a, number b, const coeffs r)
LINLINE void nlInpMult(number &a, number b, const coeffs r)
static void nlWriteFd(number n, FILE *f, const coeffs)
const ExtensionInfo & info
< [in] sqrfree poly
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
void _nlDelete_NoImm(number *a)
virtual reference Current()=0
Gets the current element in the collection (read and write).
static number nlMapLongR(number from, const coeffs src, const coeffs dst)
static const int SW_RATIONAL
set to 1 for computations over Q
const char *const nDivBy0
LINLINE BOOLEAN nlEqual(number a, number b, const coeffs r)
void nlPower(number x, int exp, number *lu, const coeffs r)
void PrintS(const char *s)
number nlQuotRem(number a, number b, number *r, const coeffs R)
static number nlReadFd(s_buff f, const coeffs)
void nlInpIntDiv(number &a, number b, const coeffs r)
number nlExtGcd(number a, number b, number *s, number *t, const coeffs)
LINLINE BOOLEAN nlIsZero(number za, const coeffs r)
(mpz_ptr), see rmodulon,h
static void nlNormalize_Gcd(number &x)
BOOLEAN _nlEqual_aNoImm_OR_bNoImm(number a, number b)
number nlShort3_noinline(number x)
static void nlClearContent(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs cf)
static CanonicalForm nlConvSingNFactoryN(number n, const BOOLEAN setChar, const coeffs)
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
number nlGetUnit(number, const coeffs)
number nlChineseRemainder(number *x, number *q, int rl, const coeffs C)
number nlBigInt(number &n)
void chineseRemainderCached(CFArray &a, CFArray &n, CanonicalForm &xnew, CanonicalForm &prod, CFArray &inv)
void gmp_numerator(const CanonicalForm &f, mpz_ptr result)
void nlNormalize(number &x, 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 nlChineseRemainderSym(number *x, number *q, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs CF)
const Variable & v
< [in] a sqrfree bivariate poly
number _nlNeg_NoImm(number a)
static number nlShort3(number x)
static number nlRandom(siRandProc p, number v2, number, const coeffs cf)
REvaluation E(1, terms.length(), IntRandom(25))
LINLINE void nlDelete(number *a, const coeffs r)
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...
BOOLEAN nlDivBy(number a, number b, const coeffs)
virtual bool MoveNext()=0
Advances the enumerator to the next element of the collection. returns true if the enumerator was suc...
BOOLEAN nlIsUnit(number a, const coeffs)
long nlInt(number &n, const coeffs r)
number _nlMult_aImm_bImm_rNoImm(number a, number b)
nMapFunc nlSetMap(const coeffs src, const coeffs dst)
number _nlAdd_aNoImm_OR_bNoImm(number a, number b)
#define GCD_NORM_COND(OLD, NEW)
long s_readlong(s_buff F)
number nlExactDiv(number a, number b, const coeffs r)
number _nlSub_aNoImm_OR_bNoImm(number a, number b)
number nlMapGMP(number from, const coeffs src, const coeffs dst)
BOOLEAN nlDBTest(number a, const char *f, const int l)
LINLINE number nlInit(long i, const coeffs r)
static char * nlCoeffString(const coeffs r)
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
number nlMapMachineInt(number from, const coeffs, const coeffs)
number nlCopyMap(number a, const coeffs, const coeffs)
static number nlMapR(number from, const coeffs src, const coeffs dst)
number nlGetNumerator(number &n, const coeffs r)
LINLINE number nlCopy(number a, const coeffs r)
void Werror(const char *fmt,...)
const CanonicalForm const CanonicalForm const CanonicalForm const CanonicalForm & cand
number nlFarey(number nN, number nP, const coeffs CF)
void gmp_denominator(const CanonicalForm &f, mpz_ptr result)
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL