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;
472 al = dest->_mp_size =
size;
474 dd = (mp_ptr)
omAlloc(
sizeof(mp_limb_t)*al);
475 for (i=0;i<
size;i++) dd[i] = qp[i];
477 nn = (mp_ptr)
omAlloc0(
sizeof(mp_limb_t)*bl);
481 ndest->_mp_alloc = ndest->_mp_size = bl;
486 al = dest->_mp_size = size+e;
488 dd = (mp_ptr)
omAlloc(
sizeof(mp_limb_t)*al);
489 for (i=0;i<
size;i++) dd[i+e] = qp[i];
490 for (i=0;i<e;i++) dd[i] = 0;
495 dest->_mp_alloc = al;
496 if (negative) mpz_neg(dest,dest);
580 int s=a->z[0]._mp_alloc;
589 int d=a->n[0]._mp_alloc;
614 long ul=mpz_get_si(i->z);
615 if (mpz_cmp_si(i->z,ul)!=0)
return 0;
621 mpz_tdiv_q(tmp,i->z,i->n);
626 if (mpz_cmp_si(tmp,ul)!=0) ul=0;
645 mpz_tdiv_q(tmp->z,i->z,i->n);
675 mpz_init_set_si(n->z,1L);
676 mpz_init_set_si(n->n,(
long)
SR_TO_INT(a));
680 mpz_init_set_si(n->z,-1L);
681 mpz_init_set_si(n->n,(
long)-
SR_TO_INT(a));
691 mpz_init_set(n->n,a->z);
697 mpz_init_set(n->z,a->n);
703 if (mpz_cmp_ui(n->n,1L)==0)
716 mpz_init_set_si(n->z,-1L);
720 mpz_init_set_si(n->z,1L);
767 mpz_divexact(u->z,a->z,b->z);
804 if (rr<0) rr+=
ABS(bb);
834 mpz_init_set(u->z,a->z);
839 else mpz_sub(u->z,u->z,rr->z);
840 mpz_divexact(u->z,u->z,b->z);
887 mpz_init_set_si(aa, ai);
894 mpz_mod(u->z, aa, b->z);
912 mpz_mod(u->z, a->z, b->z);
934 return (mpz_divisible_ui_p(a->z,
SR_TO_INT(b))!=0);
937 return mpz_divisible_p(a->z, b->z) != 0;
944 if (
nlDivBy(b, a, r))
return 2;
947 if (
nlDivBy(b, a, r))
return 1;
958 long ch = r->cfInt(c, r);
969 dummy = (mpz_ptr)
omAlloc(
sizeof(mpz_t));
970 mpz_init_set_ui(dummy, ch);
973 info.
exp = (
unsigned long) 1;
1003 if (j==1L)
return a;
1018 mpz_init_set_si(u->z,(
long)i);
1019 mpz_init_set_si(u->n,(
long)j);
1042 if (mpz_cmp(u->z,b->z)==0)
1048 mpz_init_set(u->n,b->z);
1051 else if (
SR_HDL(b) & SR_INT)
1057 mpz_init_set(u->n,a->n);
1077 mpz_init_set(u->n,b->z);
1078 if (a->s<2) mpz_mul(u->n,u->n,a->n);
1079 if (b->s<2) mpz_mul(u->z,u->z,b->n);
1087 if (mpz_cmp_si(u->n,1L)==0)
1121 mpz_pow_ui((*u)->z,x->z,(
unsigned long)exp);
1124 if (mpz_cmp_si(x->n,1L)==0)
1132 mpz_pow_ui((*u)->n,x->n,(
unsigned long)exp);
1144 if (exp<0)
Print(
"nlPower: neg. exp. %d\n",exp);
1208 if((i==0L)||(j==0L))
1226 if (((!(
SR_HDL(a) & SR_INT))&&(a->s<2))
1231 unsigned long t=mpz_gcd_ui(
NULL,b->z,(
long)aa);
1241 unsigned long t=mpz_gcd_ui(
NULL,a->z,(
long)bb);
1252 result->debug=123456;
1254 mpz_init(result->z);
1255 mpz_gcd(result->z,a->z,b->z);
1314 if (mpz_cmp_ui(x->z,0L)==0)
1321 if (mpz_cmp(x->z,x->n)==0)
1344 if (mpz_cmp_si(x->n,1L)==0)
1354 mpz_gcd(gcd,x->z,x->n);
1356 if (mpz_cmp_si(gcd,1L)!=0)
1358 mpz_divexact(x->z,x->z,gcd);
1359 mpz_divexact(x->n,x->n,gcd);
1360 if (mpz_cmp_si(x->n,1L)==0)
1389 result->debug=123456;
1394 mpz_init(result->z);
1398 mpz_gcd(gcd,a->z,b->n);
1399 if (mpz_cmp_si(gcd,1L)!=0)
1402 mpz_init_set(bt,b->n);
1403 mpz_divexact(bt,bt,gcd);
1407 mpz_mul(result->z,bt,a->z);
1414 mpz_mul(result->z,b->n,a->z);
1439 const unsigned long PP =
p;
1442 number
z =
n_Init( static_cast<long>(mpz_fdiv_ui(q->z, PP)), Zp );
1448 number
n =
n_Init( static_cast<long>(mpz_fdiv_ui(q->n, PP)), Zp );
1477 WarnS(
"Omitted denominator during coefficient mapping !");
1479 mpz_set((mpz_ptr) n, i->z);
1494 if (!(
SR_HDL(n) & SR_INT))
1503 mpz_init_set(u->z,n->n);
1523 if (!(
SR_HDL(n) & SR_INT))
1530 mpz_init_set(u->z,n->z);
1553 if (a->s!=0)
return FALSE;
1554 number
n=
b; b=
a; a=
n;
1561 if ((((
long)a) > 0L) && (
mpz_isNeg(b->z)))
1563 if ((((
long)a) < 0L) && (!
mpz_isNeg(b->z)))
1566 mpz_init_set(bb,b->n);
1568 bo=(mpz_cmp(bb,b->z)==0);
1573 if (((a->s==1) && (b->s==3))
1574 || ((b->s==1) && (a->s==3)))
1582 mpz_init_set(aa,a->z);
1583 mpz_init_set(bb,b->z);
1584 if (a->s<2) mpz_mul(bb,bb,a->n);
1585 if (b->s<2) mpz_mul(aa,aa,b->n);
1586 bo=(mpz_cmp(aa,bb)==0);
1605 mpz_init_set(b->n,a->n);
1607 mpz_init_set(b->z,a->z);
1645 #define GCD_NORM_COND(OLD,NEW) (mpz_size1(NEW->z)>mpz_size1(OLD->z)) 1651 mpz_gcd(gcd,x->z,x->n);
1653 if (mpz_cmp_si(gcd,1L)!=0)
1655 mpz_divexact(x->z,x->z,gcd);
1656 mpz_divexact(x->n,x->n,gcd);
1657 if (mpz_cmp_si(x->n,1L)==0)
1690 mpz_add(u->z,b->z,x);
1692 if (mpz_cmp_ui(u->z,0L)==0)
1698 if (mpz_cmp(u->z,b->n)==0)
1704 mpz_init_set(u->n,b->n);
1736 mpz_mul(x,b->z,a->n);
1737 mpz_mul(u->z,a->z,b->n);
1738 mpz_add(u->z,u->z,x);
1741 if (mpz_cmp_ui(u->z,0L)==0)
1748 mpz_mul(u->n,a->n,b->n);
1749 if (mpz_cmp(u->z,u->n)==0)
1762 mpz_mul(u->z,b->z,a->n);
1763 mpz_add(u->z,u->z,a->z);
1764 if (mpz_cmp_ui(u->z,0L)==0)
1770 if (mpz_cmp(u->z,a->n)==0)
1776 mpz_init_set(u->n,a->n);
1791 mpz_mul(u->z,a->z,b->n);
1792 mpz_add(u->z,u->z,b->z);
1793 if (mpz_cmp_ui(u->z,0L)==0)
1799 if (mpz_cmp(u->z,b->n)==0)
1805 mpz_init_set(u->n,b->n);
1812 mpz_add(u->z,a->z,b->z);
1837 mpz_add(a->z,a->z,x);
1855 else if (
SR_HDL(a) & SR_INT)
1871 mpz_add(u->z,b->z,x);
1874 mpz_init_set(u->n,b->n);
1909 mpz_mul(x,b->z,a->n);
1910 mpz_mul(y,a->z,b->n);
1914 mpz_mul(a->n,a->n,b->n);
1923 mpz_mul(x,b->z,a->n);
1924 mpz_add(a->z,a->z,x);
1942 mpz_mul(x,a->z,b->n);
1943 mpz_add(a->z,b->z,x);
1945 mpz_init_set(a->n,b->n);
1952 mpz_add(a->z,a->z,b->z);
1981 mpz_sub(u->z,x,b->z);
1983 if (mpz_cmp_ui(u->z,0L)==0)
1989 if (mpz_cmp(u->z,b->n)==0)
1995 mpz_init_set(u->n,b->n);
2018 else if (
SR_HDL(b) & SR_INT)
2028 mpz_sub(u->z,a->z,x);
2030 if (mpz_cmp_ui(u->z,0L)==0)
2036 if (mpz_cmp(u->z,a->n)==0)
2042 mpz_init_set(u->n,a->n);
2079 mpz_mul(x,b->z,a->n);
2080 mpz_mul(y,a->z,b->n);
2084 if (mpz_cmp_ui(u->z,0L)==0)
2091 mpz_mul(u->n,a->n,b->n);
2092 if (mpz_cmp(u->z,u->n)==0)
2107 mpz_mul(x,b->z,a->n);
2108 mpz_sub(u->z,a->z,x);
2110 if (mpz_cmp_ui(u->z,0L)==0)
2116 if (mpz_cmp(u->z,a->n)==0)
2122 mpz_init_set(u->n,a->n);
2139 mpz_mul(x,a->z,b->n);
2140 mpz_sub(u->z,x,b->z);
2142 if (mpz_cmp_ui(u->z,0L)==0)
2148 if (mpz_cmp(u->z,b->n)==0)
2154 mpz_init_set(u->n,b->n);
2161 mpz_sub(u->z,a->z,b->z);
2205 if (u->s==1) u->s=0;
2208 mpz_mul_ui(u->z,b->z,(
unsigned long)
SR_TO_INT(a));
2220 mpz_mul_ui(u->z,b->z,(
unsigned long)-
SR_TO_INT(a));
2226 if (mpz_cmp(u->z,b->n)==0)
2232 mpz_init_set(u->n,b->n);
2242 mpz_mul(u->z,a->z,b->z);
2252 if (mpz_cmp(u->z,b->n)==0)
2258 mpz_init_set(u->n,b->n);
2266 if (mpz_cmp(u->z,a->n)==0)
2272 mpz_init_set(u->n,a->n);
2278 mpz_mul(u->n,a->n,b->n);
2279 if (mpz_cmp(u->z,u->n)==0)
2348 mpz_init_set_si(z->z,i);
2362 mpz_init_set_si(z->z,(
long)i);
2363 mpz_init_set_si(z->n,(
long)j);
2375 mpz_init_set(z->z,i);
2376 mpz_init_set(z->n,j);
2402 #if defined(DO_LINLINE) || !defined(P_NUMBERS_H) 2421 #if MAX_NUM_SIZE == 60 2422 if (((i << 3) >> 3) == i) n=
INT_TO_SR(i);
2426 if ( ((((
long)ii)==i) && ((ii << 3) >> 3) == ii )) n=
INT_TO_SR(ii);
2450 if (mpz_cmp_si(a->z,0L)==0)
2452 printf(
"gmp-0 in nlIsZero\n");
2518 if ( ((r << 1) >> 1) == r )
2519 return (number)(long)r;
2537 if ( ((r << 1) >> 1) == r )
2560 number u=((number) ((r>>1)+
SR_INT));
2561 if (((((LONG)
SR_HDL(u))<<1)>>1)==
SR_HDL(u))
return (u);
2584 if ( ((r << 1) >> 1) == r )
2586 return (number)(long)r;
2608 mpz_mul(aa->z,a->z,b->z);
2613 mpz_init_set(a->n,b->n);
2621 mpz_mul(a->n,a->n,b->n);
2627 #endif // DO_LINLINE 2636 else mpz_init_set(m, (mpz_ptr)n->z);
2647 mpz_init_set(z->z, m);
2673 mpz_init_set(aa, a->z);
2681 mpz_init_set(bb, b->z);
2683 mpz_t erg; mpz_t bs; mpz_t bt;
2688 mpz_gcdext(erg, bs, bt, aa, bb);
2690 mpz_div(aa, aa, erg);
2713 else if (
SR_HDL(a) & SR_INT)
2726 else if (
SR_HDL(b) & SR_INT)
2733 rr = mpz_divmod_ui(qq, rrr, a->z, (
unsigned long)
ABS(
SR_TO_INT(b)));
2747 mpz_divmod(qq, rr, a->z, b->z);
2767 mpz_gcd(a->z,a->z,b->z);
2784 else mpz_sub(a->z,a->z,rr->z);
2785 mpz_divexact(a->z,a->z,b->z);
2792 mpz_t tmp; mpz_init(tmp);
2795 else mpz_init_set(N,nN->z);
2797 else mpz_init_set(P,nP->z);
2800 mpz_init_set_si(A,0L);
2801 mpz_init_set_ui(B,(
unsigned long)1);
2802 mpz_init_set_si(C,0L);
2806 while(mpz_cmp_si(N,0L)!=0)
2809 mpz_add(tmp,tmp,tmp);
2810 if (mpz_cmp(tmp,P)<0)
2819 if (mpz_cmp_ui(tmp,1)==0)
2826 mpz_init_set(z->z,N);
2827 mpz_init_set(z->n,B);
2840 mpz_divmod(tmp,D,E,N);
2863 mpz_init((*s)->z); (*s)->s=3;
2865 mpz_init((*t)->z); (*t)->s=3;
2867 mpz_init(g->z); g->s=3;
2875 aa=(mpz_ptr)
omAlloc(
sizeof(mpz_t));
2884 bb=(mpz_ptr)
omAlloc(
sizeof(mpz_t));
2891 mpz_gcdext(g->z,(*s)->z,(*t)->z,aa,bb);
2911 PrintS(
"// characteristic : 0\n");
2913 PrintS(
"// coeff. ring is : Integers\n");
2924 for(i=rl-1;i>=0;i--)
2926 X[
i]=CF->convSingNFactoryN(x[i],
FALSE,CF);
2927 Q[
i]=CF->convSingNFactoryN(q[i],
FALSE,CF);
2934 number
n=CF->convFactoryNSingN(xnew,CF);
2937 number
p=CF->convFactoryNSingN(qnew,CF);
2941 number n2=
nlSub(n,p,CF);
2961 numberCollectionEnumerator.
Reset();
2963 if( !numberCollectionEnumerator.
MoveNext() )
2978 int normalcount = 0;
2981 number&
n = numberCollectionEnumerator.
Current();
2993 }
while (numberCollectionEnumerator.
MoveNext() );
3000 numberCollectionEnumerator.
Reset();
3002 while (numberCollectionEnumerator.
MoveNext() )
3004 number&
n = numberCollectionEnumerator.
Current();
3006 if( (--normalcount) <= 0)
3020 numberCollectionEnumerator.
Reset();
3022 while (numberCollectionEnumerator.
MoveNext() )
3024 number& nn = numberCollectionEnumerator.
Current();
3034 cand =
nlNeg(cand,cf);
3037 numberCollectionEnumerator.
Reset();
3039 while (numberCollectionEnumerator.
MoveNext() )
3041 number&
n = numberCollectionEnumerator.
Current();
3052 numberCollectionEnumerator.
Reset();
3054 if( !numberCollectionEnumerator.
MoveNext() )
3077 number& cand1 = numberCollectionEnumerator.
Current();
3082 if ((!(
SR_HDL(cand1)&SR_INT))
3087 mpz_init_set(cand->z, cand1->n);
3092 mpz_lcm(cand->z, cand->z, cand1->n);
3097 while (numberCollectionEnumerator.
MoveNext() );
3112 numberCollectionEnumerator.
Reset();
3113 while (numberCollectionEnumerator.
MoveNext() )
3115 number&
n = numberCollectionEnumerator.
Current();
3127 numberCollectionEnumerator.
Reset();
3130 cand =
nlNeg(cand, cf);
3134 while (numberCollectionEnumerator.
MoveNext() )
3136 number &
n = numberCollectionEnumerator.
Current();
3144 if (r->cfDiv==
nlDiv)
return (
char*)
"QQ";
3145 else return (
char*)
"ZZ";
3164 #if SIZEOF_LONG == 4 3171 fprintf(f,
"4 %d ",nnn);
3176 mpz_init_set_si(tmp,nn);
3187 fprintf(f,
"%d ",n->s+5);
3228 #if SIZEOF_LONG == 8 3257 #if SIZEOF_LONG == 8 3263 default:
Werror(
"error in reading number: invalid subtype %d",sub_type);
3296 number c=
nlDiv(a,b,cf);
3327 r->cfSubringGcd =
nlGcd;
3351 r->cfInpNeg =
nlNeg;
3397 r->has_simple_Alloc=
FALSE;
3398 r->has_simple_Inverse=
FALSE;
3405 number nlMod(number
a, number
b)
3427 mpz_mod(r->z,al->z,bl->z);
3432 LONG ui=(int)mpz_get_si(&r->z);
3433 if ((((ui<<3)>>3)==ui)
3434 && (mpz_cmp_si(
x->z,(
long)ui)==0))
3444 #endif // not P_NUMBERS_H 3445 #endif // LONGRAT_CC
number nlGetUnit(number n, const coeffs r)
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)
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)
number nlModP(number q, const coeffs Q, const coeffs Zp)
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)
number nlCopyMap(number a, 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 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)
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