Changeset c879ee in git
- Timestamp:
- Oct 19, 2012, 6:38:54 PM (11 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '00e2e9c41af3fde1273eb3633f4c0c7c3db2579d')
- Children:
- 05fd55e34baa83465ce4306966c9011d1a156232
- Parents:
- 1bc7201c1a771fb5cc842ca4f475ba3ea91e697963e72b40a6237e50811b0e8745201177d25cb979
- Files:
-
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
Tst/Old/m17ex.res.gz.uu
r1bc7201 rc879ee 1 begin 64 0m17ex.res.gz2 M'XL(" (8/CDP``VTQ-V5X+G)E<P"-4CU/PS`0W?,K3A5#OAIJ)TU3JC`@EDJ(3 M I=U002%-BJ625K$K^?CUG)O4*0P(#_;9?N_=O=.MUH_+9P!@][2UHME!"_DD4 M ='6(7K@]+IQ5#^`&<#SL$6K(8:Y9.F:99C'R,5TXQ@$=$TS.KPQY$*<ZP\3R5 M XPCL"@@SPZF!3C$E8MKQ8DQ)C.,LF&,VI$Y,ZMM;DQ9\<#41D7NO_'Q)QUR;6 M (I@V-6#B6=K49*R+4AU:\56YM;=P7MCFSJ'7-PKR>1?Q36Y%>HWN(][D8ST-7 M D#N$.=-8R$)N]=.^K+92I[:1?2H)1;.%S]->B>->E$*)2H9@2;.H(]6BE:JG8 M @"`2E(=&JJ)1D<5FT:7E._+N8A+HS/-=S:DF;VC/_/Z'S]UOGVSP:9C6G,Z,9 M U6MO[*+))KVW]4<%LOBL0#10?A1MJ:I62"5*X'<6S**KV>%7LT,"OD_]V5:U10 M :+I_W[>T8:+^LL?B_]L+<#!'*E?>>&@GD=$X/2T?8*2DBO;B?;2@X(U:KT[211 .9=[BQOD&`C*U1A0#````1 begin 644 m17ex.res.gz 2 M'XL("-SF^D\``VTQ-V5X+G)E<P"-4DM/PD`0OO=73(B'OJCLMI0BJ0?CA<1X 3 M@9M!4TN+FV`AW279\=<[2\L6/1A[V.[C>\PWF=7Z<?D,`.R>EE8T.V@AGX2N 4 M#M$+M\>%L^H!W`".ASU"#3G,-4O'+-,L1CZF`\<XH-\$D_,M0Q[$J<XPL?PX 5 M`OL%A)GAU$"GF!(Q[7@QIB3&<1;,,1NL$V-]>VMLP0=7$Q&Y]\K/AW3,M2F" 6 M:5,#)IZE38UC793JT(JORJV]A?/"-G<.W;[1)I]W.[[)K4BOT3W$FWRLIP%R 7 MAS!G&@M9R*U^VI?55NK4-K*WDE`T6_@\[94X[D4IE*AD")8TBSI2+5JI>@H( 8 M(D%Y:*0J&A59;!9=6KZC["XF@<X\W]6<:O*&]LSO?^3<_<[)AIR&:</IS$2] 9 MSL8NFFS29UM_5""+SPI$`^5'T9)+U0JI1`G\SJ)9=#4\_&IX2,'WJ4';JA9- 10 M]^[[EC:,U%_Y6/S_?`$.Z4CE*AP/[2@RFJ>GY0.,E%317KR/%K1YH]ZKDW29 11 -M[AQO@%*)IX/%0,````` 12 12 ` 13 13 end -
Tst/Old/m17ex.stat
r1bc7201 rc879ee 1 1 >> tst_memory_0 :: 1 284378480:3115- 13145 :3-1-1:ix86-Linux:mamawutz:171372 1292524760:3120- 13145 :3-1-2:ix86-Linux:mamawutz:1716362 1 >> tst_memory_1 :: 1 284378480:3115- 13145 :3-1-1:ix86-Linux:mamawutz:667288 1292524760:3120- 13145 :3-1-2:ix86-Linux:mamawutz:6673363 1 >> tst_memory_2 :: 1 284378480:3115- 13145 :3-1-1:ix86-Linux:mamawutz:700072 1292524760:3120- 13145 :3-1-2:ix86-Linux:mamawutz:7001204 1 >> tst_timer_1 :: 1 284378480:3115- 13145 :3-1-1:ix86-Linux:mamawutz:5 1292524760:3120- 13145 :3-1-2:ix86-Linux:mamawutz:51 1 >> tst_memory_0 :: 1341843164:3144- exported :3-1-4:ix86-Linux:mamawutz:180696 2 1 >> tst_memory_1 :: 1341843164:3144- exported :3-1-4:ix86-Linux:mamawutz:2240284 3 1 >> tst_memory_2 :: 1341843164:3144- exported :3-1-4:ix86-Linux:mamawutz:2273068 4 1 >> tst_timer_1 :: 1341843164:3144- exported :3-1-4:ix86-Linux:mamawutz:2 -
Tst/Old/m17ex.tst
r1bc7201 rc879ee 8 8 poly g = (y4+x8)*(x2+y2); 9 9 factorize(g); 10 // The same in char cteristic 2:10 // The same in characteristic 2: 11 11 ring r =2,(x,y),dp; 12 12 poly g = (y4+x8)*(x2+y2); -
factory/FLINTconvert.cc
r1bc7201 rc879ee 140 140 ulong coeff= nmod_poly_get_coeff_ui (poly, i); 141 141 if (!coeff == 0) 142 result += CanonicalForm ( coeff)*power (x,i);142 result += CanonicalForm ((long)coeff)*power (x,i); 143 143 } 144 144 return result; -
factory/README
r1bc7201 rc879ee 338 338 continuation): 339 339 340 g++ -c /usr/local/include/templates/ftmpl_inst.cc \ 341 -fno-implicit-templates -O2 -fomit-frame-pointer -o ftmpl_inst.o 342 g++ -c application.cc -fno-implicit-templates -O2 -fomit-frame-pointer \ 343 ftmpl_inst.o -lcf -lcfmem -lm -lgmp 340 g++ -c /usr/local/include/templates/ftmpl_inst.cc -fno-implicit-templates -O2 -fomit-frame-pointer -o ftmpl_inst.o 341 g++ -c application.cc -fno-implicit-templates -O2 -fomit-frame-pointer ftmpl_inst.o -lcf -lcfmem -lm -lgmp 344 342 345 343 This should work fine provided that you installed Factory in a location -
factory/algext.cc
r63e72b4 rc879ee 548 548 return; 549 549 m *= (x - alpha); 550 if( gnew == gm) // gnew did not change551 { 552 cf = tryvcontent(g m, Variable(2), M, fail);550 if((firstLC(gnew) == gamma) || (gnew == gm)) // gnew did not change 551 { 552 cf = tryvcontent(gnew, Variable(2), M, fail); 553 553 if(fail) 554 554 return; 555 555 divides = true; 556 g_image= g m;556 g_image= gnew; 557 557 g_image.tryDiv (cf, M, fail); 558 558 if(fail) … … 692 692 } 693 693 // here: a is the biggest alg. var in f and g AND some of f,g is in extension 694 // (in the sequel b is used to swap alg/poly vars)695 694 setReduce(a,false); // do not reduce expressions modulo mipo 696 695 tmp = getMipo(a); … … 703 702 mv = i; 704 703 // here: mv is level of the largest variable in f, g 705 b = Variable(mv+1);706 704 bound = new int[mv+1]; // 'bound' could be indexed from 0 to mv, but we will only use from 1 to mv 707 705 other = new int[mv+1]; … … 750 748 if(isEqual(bound, other, 1, mv)) // equal 751 749 { 752 chineseRemainder( D, q, replacevar( mapinto(Dp), a, b), p, tmp, newq );750 chineseRemainder( D, q, mapinto(Dp), p, tmp, newq ); 753 751 // tmp = Dp mod p 754 752 // tmp = D mod q … … 758 756 D = tmp; 759 757 On( SW_RATIONAL ); 760 tmp = replacevar( Farey( D, q ), b, a ); // Farey and switch back to alg var 758 tmp = Farey( D, q ); // Farey 759 tmp *= bCommonDen (tmp); 761 760 setReduce(a,true); // reduce expressions modulo mipo 762 761 On( SW_RATIONAL ); // needed by fdivides … … 780 779 // here: isLess(other, bound, 1, mv) ) ==> all previous primes unlucky 781 780 q = p; 782 D = replacevar( mapinto(Dp), a, b); // shortcut CRA // shortcut CRA781 D = mapinto(Dp); // shortcut CRA // shortcut CRA 783 782 for(int i=1; i<=mv; i++) // tighten bound 784 783 bound[i] = other[i]; -
factory/canonicalform.cc
r1bc7201 rc879ee 217 217 218 218 //{{{ conversion functions 219 int 219 long 220 220 CanonicalForm::intval() const 221 221 { … … 1303 1303 if ( is_imm( value ) ) { 1304 1304 ASSERT( is_imm( value ) == INTMARK, "sqrt() not implemented" ); 1305 intn = imm2int( value );1305 long n = imm2int( value ); 1306 1306 ASSERT( n >= 0, "arg to sqrt() less than zero" ); 1307 1307 if ( n == 0 || n == 1 ) 1308 1308 return CanonicalForm( n ); 1309 1309 else { 1310 intx, y = n;1310 long x, y = n; 1311 1311 do { 1312 1312 x = y; 1313 1313 // the intermediate result may not fit into an 1314 1314 // integer, but the result does 1315 y = (unsigned int)(x + n/x)/2;1315 y = (unsigned long)(x + n/x)/2; 1316 1316 } while ( y < x ); 1317 1317 return CanonicalForm( x ); … … 1340 1340 { 1341 1341 ASSERT( is_imm( value ) == INTMARK, "ilog2() not implemented" ); 1342 inta = imm2int( value );1342 long a = imm2int( value ); 1343 1343 ASSERT( a > 0, "arg to ilog2() less or equal zero" ); 1344 1344 int n = -1; … … 1584 1584 // calculate gcd using standard integer 1585 1585 // arithmetic 1586 intfInt = imm2int( f.value );1587 intgInt = imm2int( g.value );1586 long fInt = imm2int( f.value ); 1587 long gInt = imm2int( g.value ); 1588 1588 1589 1589 if ( fInt < 0 ) fInt = -fInt; … … 1592 1592 if ( gInt > fInt ) 1593 1593 { 1594 intswap = gInt;1594 long swap = gInt; 1595 1595 gInt = fInt; 1596 1596 fInt = swap; … … 1601 1601 { 1602 1602 // calculate (fInt, gInt) = (gInt, fInt%gInt) 1603 intr = fInt % gInt;1603 long r = fInt % gInt; 1604 1604 fInt = gInt; 1605 1605 gInt = r; … … 1658 1658 // calculate extended gcd using standard integer 1659 1659 // arithmetic 1660 intfInt = imm2int( f.value );1661 intgInt = imm2int( g.value );1660 long fInt = imm2int( f.value ); 1661 long gInt = imm2int( g.value ); 1662 1662 1663 1663 // to avoid any system dpendencies with `%', we work … … 1668 1668 // swap fInt and gInt 1669 1669 if ( gInt > fInt ) { 1670 intswap = gInt;1670 long swap = gInt; 1671 1671 gInt = fInt; 1672 1672 fInt = swap; 1673 1673 } 1674 1674 1675 int u = 1; intv = 0;1676 int uNext = 0; intvNext = 1;1675 long u = 1; long v = 0; 1676 long uNext = 0; long vNext = 1; 1677 1677 1678 1678 // at any step, we have: … … 1682 1682 // and gInt, resp., at the beginning 1683 1683 while ( gInt ) { 1684 intr = fInt % gInt;1685 intq = fInt / gInt;1686 intuSwap = u - q * uNext;1687 intvSwap = v - q * vNext;1684 long r = fInt % gInt; 1685 long q = fInt / gInt; 1686 long uSwap = u - q * uNext; 1687 long vSwap = v - q * vNext; 1688 1688 1689 1689 // update variables … … 1695 1695 1696 1696 // now, assign to a and b 1697 intfTest = imm2int( f.value );1698 intgTest = imm2int( g.value );1697 long fTest = imm2int( f.value ); 1698 long gTest = imm2int( g.value ); 1699 1699 if ( gTest > fTest ) { 1700 1700 a = v; b = u; … … 1804 1804 int what = is_imm( value ); 1805 1805 if ( what == FFMARK ) 1806 return CanonicalForm( CFFactory::basic( FiniteFieldDomain, 0 ) );1806 return CanonicalForm( CFFactory::basic( FiniteFieldDomain, 0L ) ); 1807 1807 else if ( what == GFMARK ) 1808 return CanonicalForm( CFFactory::basic( GaloisFieldDomain, 0 ) );1808 return CanonicalForm( CFFactory::basic( GaloisFieldDomain, 0L ) ); 1809 1809 else if ( what ) 1810 return CanonicalForm( CFFactory::basic( IntegerDomain, 0 ) );1810 return CanonicalForm( CFFactory::basic( IntegerDomain, 0L ) ); 1811 1811 else 1812 1812 return CanonicalForm( value->genZero() ); … … 1818 1818 int what = is_imm( value ); 1819 1819 if ( what == FFMARK ) 1820 return CanonicalForm( CFFactory::basic( FiniteFieldDomain, 1 ) );1820 return CanonicalForm( CFFactory::basic( FiniteFieldDomain, 1L ) ); 1821 1821 else if ( what == GFMARK ) 1822 return CanonicalForm( CFFactory::basic( GaloisFieldDomain, 1 ) );1822 return CanonicalForm( CFFactory::basic( GaloisFieldDomain, 1L ) ); 1823 1823 else if ( what ) 1824 return CanonicalForm( CFFactory::basic( IntegerDomain, 1 ) );1824 return CanonicalForm( CFFactory::basic( IntegerDomain, 1L ) ); 1825 1825 else 1826 1826 return CanonicalForm( value->genOne() ); -
factory/canonicalform.h
r1bc7201 rc879ee 69 69 CF_INLINE CanonicalForm( InternalCF* ); 70 70 CF_INLINE CanonicalForm( const int ); 71 CF_INLINE CanonicalForm( const long ); 71 72 CF_INLINE CanonicalForm( const Variable & ); 72 73 CF_INLINE CanonicalForm( const Variable &, int ); … … 100 101 101 102 // conversion functions 102 intintval() const;103 long intval() const; 103 104 CanonicalForm mapinto () const; 104 105 … … 123 124 // assignment operators 124 125 CF_NO_INLINE CanonicalForm& operator = ( const CanonicalForm& ); 125 CF_NO_INLINE CanonicalForm& operator = ( const int);126 CF_NO_INLINE CanonicalForm& operator = ( const long ); 126 127 127 128 CanonicalForm& operator += ( const CanonicalForm& ); -
factory/cf_chinese.cc
r63e72b4 rc879ee 227 227 } 228 228 else 229 result += power( x, i.exp() ) * Farey(c,q); 230 #else 231 if (c.inZ()) 232 result += power( x, i.exp() ) * Farey_n(c,q); 233 else 234 result += power( x, i.exp() ) * Farey(c,q); 229 235 #endif 230 result += power( x, i.exp() ) * Farey_n(c,q);231 236 } 232 237 else -
factory/cf_factor.cc
r1bc7201 rc879ee 89 89 } 90 90 91 #if 091 #if 1 92 92 //#ifndef NOSTREAMIO 93 93 void out_cf(const char *s1,const CanonicalForm &f,const char *s2) -
factory/cf_factory.cc
r1bc7201 rc879ee 25 25 26 26 InternalCF * 27 CFFactory::basic ( intvalue )27 CFFactory::basic ( long value ) 28 28 { 29 29 if ( currenttype == IntegerDomain ) … … 50 50 51 51 InternalCF * 52 CFFactory::basic ( int type, intvalue )52 CFFactory::basic ( int type, long value ) 53 53 { 54 54 if ( type == IntegerDomain ) … … 204 204 205 205 InternalCF * 206 CFFactory::basic ( int type, intvalue, bool nonimm )206 CFFactory::basic ( int type, long value, bool nonimm ) 207 207 { 208 208 if ( nonimm ) … … 231 231 232 232 InternalCF * 233 CFFactory::rational ( int num, intden )233 CFFactory::rational ( long num, long den ) 234 234 { 235 235 InternalRational * res = new InternalRational( num, den ); -
factory/cf_factory.h
r1bc7201 rc879ee 21 21 static int gettype () { return currenttype; } 22 22 static void settype ( int type ); 23 static InternalCF * basic ( intvalue );24 static InternalCF * basic ( int type, intvalue );23 static InternalCF * basic ( long value ); 24 static InternalCF * basic ( int type, long value ); 25 25 static InternalCF * basic ( const char * str ); 26 26 static InternalCF * basic ( const char * str, int base ); 27 27 static InternalCF * basic ( int type, const char * const str ); 28 static InternalCF * basic ( int type, intvalue, bool nonimm );28 static InternalCF * basic ( int type, long value, bool nonimm ); 29 29 static InternalCF * basic ( const mpz_ptr num ); 30 static InternalCF * rational ( int num, intden );30 static InternalCF * rational ( long num, long den ); 31 31 static InternalCF * rational ( const mpz_ptr num, const mpz_ptr den, bool normalize ); 32 32 static InternalCF * poly ( const Variable & v, int exp, const CanonicalForm & c ); -
factory/cf_gcd_smallp.cc
r63e72b4 rc879ee 4229 4229 Evaluation result= Evaluation (A.min(), A.max()); 4230 4230 ASSERT (A.min() == 2, "expected A.min() == 2"); 4231 ASSERT (A.max() >= n, "expected A.max() >= n");4232 4231 int max_deg; 4233 4232 int k= n; -
factory/cf_inline.cc
r1bc7201 rc879ee 121 121 CF_INLINE 122 122 CanonicalForm::CanonicalForm () 123 : value( CFFactory::basic( ( int)0 ) )123 : value( CFFactory::basic( (long)0 ) ) 124 124 { 125 125 } … … 140 140 CF_INLINE 141 141 CanonicalForm::CanonicalForm ( const int i ) 142 : value( CFFactory::basic( (long)i ) ) 143 { 144 } 145 146 CF_INLINE 147 CanonicalForm::CanonicalForm ( const long i ) 142 148 : value( CFFactory::basic( i ) ) 143 149 { … … 300 306 //}}} 301 307 CF_INLINE CanonicalForm & 302 CanonicalForm::operator = ( const intcf )308 CanonicalForm::operator = ( const long cf ) 303 309 { 304 310 if ( (! is_imm( value )) && value->deleteObject() ) -
factory/facFqBivarUtil.cc
r63e72b4 rc879ee 519 519 } 520 520 521 q= newtonDiv (bufF, G, xToLOldL); 521 if (l-oldL > 0) 522 q= newtonDiv (bufF, G, xToLOldL); 523 else 524 q= 0; 522 525 q *= xToOldL; 523 526 q += oldQ; -
factory/facFqSquarefree.h
r63e72b4 rc879ee 18 18 #include "cf_factory.h" 19 19 #include "fac_sqrfree.h" 20 #include "cf_factory.h" 20 21 21 22 /// squarefree factorization over a finite field -
factory/facHensel.cc
r63e72b4 rc879ee 544 544 } 545 545 546 setReduce (alpha, false); 546 547 for (k= 0; k < factors.length(); k++) 547 548 { … … 554 555 } 555 556 } 557 setReduce (alpha, true); 556 558 setCharacteristic(0); 557 559 … … 591 593 } 592 594 setCharacteristic (p); 595 setReduce (alpha, false); 593 596 recResult= mapinto (recResult); 597 setReduce (alpha, true); 594 598 if (mipoHasDen) 595 599 { … … 606 610 coeffE= div (e, modulus); 607 611 setCharacteristic (p); 612 if (mipoHasDen) 613 setReduce (gamma, false); 614 else 615 setReduce (alpha, false); 608 616 coeffE= coeffE.mapinto(); 617 if (mipoHasDen) 618 setReduce (gamma, true); 619 else 620 setReduce (alpha, true); 609 621 if (mipoHasDen) 610 622 coeffE= replacevar (coeffE, gamma, beta); … … 619 631 { 620 632 setCharacteristic (p); 633 setReduce (alpha, false); 621 634 g= mulNTL (coeffE, j.getItem()); 622 635 g= modNTL (g, bufFactors[ii]); 636 setReduce (alpha, true); 623 637 setCharacteristic (0); 624 638 if (mipoHasDen) 625 639 { 640 setReduce (beta, false); 626 641 k.getItem() += replacevar (g.mapinto()*modulus, beta, gamma); 627 642 e -= mulNTL (replacevar (g.mapinto(), beta, gamma)*modulus, 628 643 l.getItem(), b); 644 setReduce (beta, true); 629 645 } 630 646 else -
factory/facMul.cc
r63e72b4 rc879ee 404 404 { 405 405 ZZ_p::init (convertFacCF2NTLZZ (b.getpk())); 406 ZZ_pX NTLmipo= to_ZZ_pX (convertFacCF2NTLZZX (getMipo (alpha))); 406 CanonicalForm mipo= getMipo (alpha); 407 bool is_rat= isOn (SW_RATIONAL); 408 if (!is_rat) 409 On (SW_RATIONAL); 410 mipo *=bCommonDen (mipo); 411 if (!is_rat) 412 Off (SW_RATIONAL); 413 ZZ_pX NTLmipo= to_ZZ_pX (convertFacCF2NTLZZX (mipo)); 407 414 ZZ_pE::init (NTLmipo); 408 415 ZZ_pEX NTLg= convertFacCF2NTLZZ_pEX (G, NTLmipo); -
factory/fac_ezgcd.cc
r63e72b4 rc879ee 215 215 Evaluation result= Evaluation (A.min(), A.max()); 216 216 ASSERT (A.min() == 2, "expected A.min() == 2"); 217 ASSERT (A.max() == n, "expected A.max() == n");218 217 int max_deg; 219 218 int k= n; -
factory/ffops.h
r1bc7201 rc879ee 37 37 } 38 38 39 inline long ff_norm ( const long a ) 40 { 41 long n = a % ff_prime; 42 #if defined(i386) || defined(NTL_AVOID_BRANCHING) 43 n += (n >> 31) & ff_prime; 44 return n; 45 #else 46 if (n < 0) n += ff_prime; 47 return n; 48 #endif 49 } 50 39 51 inline int ff_symmetric( const int a ) 52 { 53 if ( cf_glob_switches.isOn( SW_SYMMETRIC_FF ) ) 54 return ( a > ff_halfprime ) ? a - ff_prime : a; 55 else 56 return a; 57 } 58 59 inline long ff_symmetric( const long a ) 40 60 { 41 61 if ( cf_glob_switches.isOn( SW_SYMMETRIC_FF ) ) -
factory/gfops.cc
r1bc7201 rc879ee 222 222 } 223 223 224 long gf_gf2ff ( long a ) 225 { 226 if ( gf_iszero( a ) ) 227 return 0; 228 else 229 { 230 // starting from z^0=1, step through the table 231 // counting the steps until we hit z^a or z^0 232 // again. since we are working in char(p), the 233 // latter is guaranteed to be fulfilled. 234 long i = 0, ff = 1; 235 do 236 { 237 if ( i == a ) 238 return ff; 239 ff++; 240 i = gf_table[i]; 241 } while ( i != 0 ); 242 return -1; 243 } 244 } 245 224 246 int gf_gf2ff ( int a ) 225 247 { … … 244 266 } 245 267 246 bool gf_isff ( inta )268 bool gf_isff ( long a ) 247 269 { 248 270 if ( gf_iszero( a ) ) … … 254 276 } 255 277 } 278 279 bool gf_isff ( int a ) 280 { 281 if ( gf_iszero( a ) ) 282 return true; 283 else 284 { 285 // z^a in GF(p) iff (z^a)^p-1=1 286 return gf_isone( gf_power( a, gf_p - 1 ) ); 287 } 288 } -
factory/gfops.h
r1bc7201 rc879ee 38 38 } 39 39 40 inline bool gf_iszero ( long a ) 41 { 42 return gf_q == a; 43 } 44 40 45 inline bool gf_isone ( int a ) 46 { 47 return 0 == a; 48 } 49 50 inline bool gf_isone ( long a ) 41 51 { 42 52 return 0 == a; … … 54 64 return gf_q; 55 65 int c = 0; 66 while ( i > 1 ) { 67 c = gf_table[c]; 68 i--; 69 } 70 return c; 71 } 72 73 inline long gf_int2gf ( long i ) 74 { 75 while ( i < 0 ) 76 i += gf_p; 77 while ( i >= gf_p ) 78 i -= gf_p; 79 if ( i == 0 ) 80 return gf_q; 81 long c = 0; 56 82 while ( i > 1 ) { 57 83 c = gf_table[c]; … … 138 164 } 139 165 166 inline long gf_mul ( long a, int b ) 167 { 168 if ( a == gf_q || b == gf_q ) 169 return gf_q; 170 else { 171 long i = a + b; 172 if ( i >= gf_q1 ) i -= gf_q1; 173 return i; 174 } 175 } 176 140 177 inline int gf_div ( int a, int b ) 141 178 { … … 184 221 return gf_mul( a, gf_power( a, n-1 ) ); 185 222 } 223 224 inline long gf_power ( long a, int n ) 225 { 226 if ( n == 0 ) 227 return 0; 228 else if ( n == 1 ) 229 return a; 230 else 231 return gf_mul( a, gf_power( a, n-1 ) ); 232 } 186 233 //}}} 187 234 … … 191 238 /*BEGINPUBLIC*/ 192 239 240 long gf_gf2ff ( long a ); 193 241 int gf_gf2ff ( int a ); 194 242 243 bool gf_isff ( long a ); 195 244 bool gf_isff ( int a ); 196 245 -
factory/imm.h
r1bc7201 rc879ee 26 26 #include "int_cf.h" 27 27 28 const intINTMARK = 1;29 const intFFMARK = 2;30 const intGFMARK = 3;28 const long INTMARK = 1; 29 const long FFMARK = 2; 30 const long GFMARK = 3; 31 31 32 32 /* define type of your compilers 64 bit integer type */ … … 35 35 #endif 36 36 37 const int MINIMMEDIATE = -268435454; // -2^28-2 38 const int MAXIMMEDIATE = 268435454; // 2^28-2 37 #if SIZEOF_LONG == 4 38 const long MINIMMEDIATE = -268435454; // -2^28-2 39 const long MAXIMMEDIATE = 268435454; // 2^28-2 40 #else 41 const long MINIMMEDIATE = -(1L<<60)+2L; // -2^60-2 42 const long MAXIMMEDIATE = (1L<<60)-2L; // 2^60-2 43 #endif 44 39 45 #if defined(WINNT) && ! defined(__GNUC__) 40 46 const INT64 MINIMMEDIATELL = -268435454i64; … … 49 55 #if 1 50 56 51 inline intimm2int ( const InternalCF * const imm )52 { 53 return (( int)((long)imm)) >> 2;54 } 55 56 inline InternalCF * int2imm ( inti )57 inline long imm2int ( const InternalCF * const imm ) 58 { 59 return ((long)imm) >> 2; 60 } 61 62 inline InternalCF * int2imm ( long i ) 57 63 { 58 64 return (InternalCF*)(long)((i << 2) | INTMARK ); … … 70 76 } 71 77 72 inline InternalCF * int2imm ( inti )78 inline InternalCF * int2imm ( long i ) 73 79 { 74 80 if ( i < 0 ) … … 80 86 #endif 81 87 82 inline InternalCF * int2imm_p ( inti )88 inline InternalCF * int2imm_p ( long i ) 83 89 { 84 90 return (InternalCF*)(long)((i << 2) | FFMARK ); 85 91 } 86 92 87 inline InternalCF * int2imm_gf ( inti )93 inline InternalCF * int2imm_gf ( long i ) 88 94 { 89 95 return (InternalCF*)(long)((i << 2) | GFMARK ); … … 143 149 144 150 //{{{ conversion functions 145 inline intimm_intval ( const InternalCF* const op )151 inline long imm_intval ( const InternalCF* const op ) 146 152 { 147 153 if ( is_imm( op ) == FFMARK ) … … 253 259 inline InternalCF * imm_add ( const InternalCF * const lhs, const InternalCF * const rhs ) 254 260 { 255 intresult = imm2int( lhs ) + imm2int( rhs );261 long result = imm2int( lhs ) + imm2int( rhs ); 256 262 if ( ( result > MAXIMMEDIATE ) || ( result < MINIMMEDIATE ) ) 257 263 return CFFactory::basic( result ); … … 272 278 inline InternalCF * imm_sub ( const InternalCF * const lhs, const InternalCF * const rhs ) 273 279 { 274 intresult = imm2int( lhs ) - imm2int( rhs );280 long result = imm2int( lhs ) - imm2int( rhs ); 275 281 if ( ( result > MAXIMMEDIATE ) || ( result < MINIMMEDIATE ) ) 276 282 return CFFactory::basic( result ); … … 292 298 imm_mul ( InternalCF * lhs, InternalCF * rhs ) 293 299 { 294 INT64 result = (INT64)imm2int( lhs ) * imm2int( rhs ); 295 if ( ( result > MAXIMMEDIATELL ) || ( result < MINIMMEDIATELL ) ) { 296 InternalCF * res = CFFactory::basic( IntegerDomain, imm2int( lhs ), true ); 300 long a = imm2int( lhs ); 301 long b = imm2int( rhs ); 302 INT64 result = (INT64)a * (INT64)b; 303 if ( ( a!=0L ) && ((result/a!=b) 304 ||(result>MAXIMMEDIATE)||(result<MINIMMEDIATE) ) ) 305 { 306 InternalCF * res = CFFactory::basic( IntegerDomain, a, true ); 297 307 return res->mulcoeff( rhs ); 298 308 } 299 309 else 300 return int2imm( (int)result );310 return int2imm( result ); 301 311 } 302 312 … … 313 323 inline InternalCF * imm_div ( const InternalCF * const lhs, const InternalCF * const rhs ) 314 324 { 315 inta = imm2int( lhs );316 intb = imm2int( rhs );325 long a = imm2int( lhs ); 326 long b = imm2int( rhs ); 317 327 if ( a > 0 ) 318 328 return int2imm( a / b ); … … 328 338 return CFFactory::rational( imm2int( lhs ), imm2int( rhs ) ); 329 339 else { 330 inta = imm2int( lhs );331 intb = imm2int( rhs );340 long a = imm2int( lhs ); 341 long b = imm2int( rhs ); 332 342 if ( a > 0 ) 333 343 return int2imm( a / b ); … … 354 364 return int2imm( 0 ); 355 365 else { 356 inta = imm2int( lhs );357 intb = imm2int( rhs );366 long a = imm2int( lhs ); 367 long b = imm2int( rhs ); 358 368 if ( a > 0 ) 359 369 if ( b > 0 ) … … 363 373 else 364 374 if ( b > 0 ) { 365 intr = (-a) % b;375 long r = (-a) % b; 366 376 return int2imm( (r==0) ? r : b-r ); 367 377 } 368 378 else { 369 intr = (-a) % (-b);379 long r = (-a) % (-b); 370 380 return int2imm( (r==0) ? r : -b-r ); 371 381 } … … 387 397 if ( cf_glob_switches.isOn( SW_RATIONAL ) ) { 388 398 q = imm_divrat( lhs, rhs ); 389 r = CFFactory::basic( 0 );399 r = CFFactory::basic( 0L ); 390 400 } 391 401 else { -
factory/int_cf.cc
r1bc7201 rc879ee 87 87 InternalCF::den () 88 88 { 89 return CFFactory::basic( 1 );89 return CFFactory::basic( 1L ); 90 90 } 91 91 //}}} … … 129 129 { 130 130 ASSERT1( 0, "bgcd() not implemented for class %s", this->classname() ); 131 return CFFactory::basic( 0 );131 return CFFactory::basic( 0L ); 132 132 } 133 133 … … 136 136 { 137 137 ASSERT1( 0, "bgcd() not implemented for class %s", this->classname() ); 138 return CFFactory::basic( 0 );138 return CFFactory::basic( 0L ); 139 139 } 140 140 //}}} … … 147 147 ASSERT1( 0, "bextgcd() not implemented for class %s", this->classname() ); 148 148 a = 0; b = 0; 149 return CFFactory::basic( 0 );149 return CFFactory::basic( 0L ); 150 150 } 151 151 … … 155 155 ASSERT1( 0, "bextgcd() not implemented for class %s", this->classname() ); 156 156 a = 0; b = 0; 157 return CFFactory::basic( 0 );158 } 159 //}}} 160 161 int 157 return CFFactory::basic( 0L ); 158 } 159 //}}} 160 161 long 162 162 InternalCF::intval() const 163 163 { -
factory/int_cf.h
r1bc7201 rc879ee 58 58 virtual bool isOne() const; 59 59 virtual bool isUnivariate() const { return false; } 60 virtual intintval() const;60 virtual long intval() const; 61 61 virtual int intmod( int ) const { return 0; } 62 62 virtual int sign() const PVIRT_INT("sign"); -
factory/int_int.cc
r1bc7201 rc879ee 20 20 21 21 InternalInteger::InternalInteger( const int i ) 22 { 23 mpz_init_set_si( thempi, i ); 24 } 25 26 InternalInteger::InternalInteger( const long i ) 22 27 { 23 28 mpz_init_set_si( thempi, i ); … … 221 226 { 222 227 ASSERT( ::is_imm( c ) == INTMARK, "incompatible base coefficients" ); 223 intcc = imm2int( c );228 long cc = imm2int( c ); 224 229 if ( getRefCount() > 1 ) 225 230 { … … 260 265 { 261 266 ASSERT( ::is_imm( c ) == INTMARK, "incompatible base coefficients" ); 262 intcc = imm2int( c );267 long cc = imm2int( c ); 263 268 if ( getRefCount() > 1 ) 264 269 { … … 315 320 { 316 321 ASSERT( ::is_imm( c ) == INTMARK, "incompatible base coefficients" ); 317 intcc = imm2int( c );322 long cc = imm2int( c ); 318 323 if ( getRefCount() > 1 ) 319 324 { … … 394 399 return int2imm( 1 ); 395 400 396 intcInt = imm2int( c );401 long cInt = imm2int( c ); 397 402 398 403 // trivial cases … … 480 485 } 481 486 482 intcInt = imm2int( c );487 long cInt = imm2int( c ); 483 488 484 489 // trivial cases … … 512 517 //}}} 513 518 514 intInternalInteger::intval() const515 { 516 return (int)mpz_get_si( thempi );519 long InternalInteger::intval() const 520 { 521 return mpz_get_si( thempi ); 517 522 } 518 523 -
factory/int_int.h
r1bc7201 rc879ee 65 65 } 66 66 InternalInteger( const int i ); 67 InternalInteger( const long i ); 67 68 InternalInteger( const char * str, const int base=10 ); 68 69 InternalInteger( const mpz_ptr ); … … 111 112 InternalCF * bextgcdcoeff ( InternalCF *, CanonicalForm &, CanonicalForm & ); 112 113 113 intintval() const;114 long intval() const; 114 115 115 116 int intmod( int p ) const; -
factory/int_intdiv.cc
r1bc7201 rc879ee 66 66 "math error: divide by zero" ); 67 67 68 intintC = imm2int( c );68 long intC = imm2int( c ); 69 69 70 70 if ( cf_glob_switches.isOn( SW_RATIONAL ) ) { … … 208 208 } 209 209 210 intintC = imm2int( c );210 long intC = imm2int( c ); 211 211 212 212 if ( invert ) { … … 293 293 "math error: divide by zero" ); 294 294 295 intintC = imm2int( c );295 long intC = imm2int( c ); 296 296 297 297 if ( cf_glob_switches.isOn( SW_RATIONAL ) ) { -
factory/int_poly.cc
r1bc7201 rc879ee 251 251 } 252 252 else 253 return CFFactory::basic( 0 );253 return CFFactory::basic( 0L ); 254 254 } 255 255 … … 273 273 } 274 274 else 275 return CFFactory::basic( 0 );275 return CFFactory::basic( 0L ); 276 276 } 277 277 … … 294 294 { 295 295 delete this; 296 return CFFactory::basic( 0 );296 return CFFactory::basic( 0L ); 297 297 } 298 298 } … … 311 311 } 312 312 else 313 return CFFactory::basic( 0 );313 return CFFactory::basic( 0L ); 314 314 315 315 } … … 334 334 { 335 335 delete this; 336 return CFFactory::basic( 0 );336 return CFFactory::basic( 0L ); 337 337 } 338 338 } … … 351 351 } 352 352 else 353 return CFFactory::basic( 0 );353 return CFFactory::basic( 0L ); 354 354 355 355 } … … 378 378 { 379 379 delete this; 380 return CFFactory::basic(0 );380 return CFFactory::basic(0L); 381 381 } 382 382 else 383 383 { 384 384 decRefCount(); 385 return CFFactory::basic(0 );385 return CFFactory::basic(0L); 386 386 } 387 387 } … … 441 441 { 442 442 delete this; 443 return CFFactory::basic(0 );443 return CFFactory::basic(0L); 444 444 } 445 445 else 446 446 { 447 447 decRefCount(); 448 return CFFactory::basic(0 );448 return CFFactory::basic(0L); 449 449 } 450 450 } … … 556 556 firstTerm = 0; 557 557 delete this; 558 return CFFactory::basic( 0 );558 return CFFactory::basic( 0L ); 559 559 } 560 560 } … … 570 570 } 571 571 else 572 return CFFactory::basic( 0 );572 return CFFactory::basic( 0L ); 573 573 } 574 574 } … … 581 581 InternalCF * dummy = aCoeff->tryInvert(M, fail); 582 582 if (fail) 583 return CFFactory::basic( 0 );583 return CFFactory::basic( 0L ); 584 584 if (is_imm(dummy)) dummy=this->tryMulsame(dummy, M); 585 585 else dummy = dummy->tryMulsame( this, M); … … 626 626 { 627 627 freeTermList (first); 628 return CFFactory::basic (0 );628 return CFFactory::basic (0L); 629 629 } 630 630 newcoeff= reduce (newcoeff, M); … … 659 659 firstTerm = 0; 660 660 delete this; 661 return CFFactory::basic( 0 );661 return CFFactory::basic( 0L ); 662 662 } 663 663 } … … 673 673 } 674 674 else 675 return CFFactory::basic( 0 );675 return CFFactory::basic( 0L ); 676 676 } 677 677 } … … 689 689 { 690 690 if ( deleteObject() ) delete this; 691 return CFFactory::basic( 0 );691 return CFFactory::basic( 0L ); 692 692 } 693 693 InternalPoly *aPoly = (InternalPoly*)aCoeff; … … 736 736 firstTerm = 0; 737 737 delete this; 738 return CFFactory::basic( 0 );738 return CFFactory::basic( 0L ); 739 739 } 740 740 } … … 750 750 } 751 751 else 752 return CFFactory::basic( 0 );752 return CFFactory::basic( 0L ); 753 753 } 754 754 } … … 762 762 InternalCF * dummy = acoeff->invert(); 763 763 quot = dummy->mulsame( this ); 764 rem = CFFactory::basic( 0 );764 rem = CFFactory::basic( 0L ); 765 765 } 766 766 else … … 793 793 quot = new InternalPoly( resultfirst, resultlast, var ); 794 794 else 795 quot = CFFactory::basic( 0 );795 quot = CFFactory::basic( 0L ); 796 796 if ( first ) 797 797 if ( first->exp == 0 ) … … 803 803 rem = new InternalPoly( first, last, var ); 804 804 else 805 rem = CFFactory::basic( 0 );805 rem = CFFactory::basic( 0L ); 806 806 } 807 807 } … … 853 853 quot = new InternalPoly( resultfirst, resultlast, var ); 854 854 else 855 quot = CFFactory::basic( 0 );855 quot = CFFactory::basic( 0L ); 856 856 if ( first ) 857 857 if ( first->exp == 0 ) … … 863 863 rem = new InternalPoly( first, last, var ); 864 864 else 865 rem = CFFactory::basic( 0 );865 rem = CFFactory::basic( 0L ); 866 866 } 867 867 else … … 882 882 return false; 883 883 quot = dummy->tryMulsame( this, M); 884 rem = CFFactory::basic( 0 );884 rem = CFFactory::basic( 0L ); 885 885 if (fail) 886 886 return false; … … 928 928 quot = new InternalPoly( resultfirst, resultlast, var ); 929 929 else 930 quot = CFFactory::basic( 0 );930 quot = CFFactory::basic( 0L ); 931 931 if ( first ) 932 932 if ( first->exp == 0 ) … … 939 939 if (first->coeff.isZero()) 940 940 { 941 rem= CFFactory::basic (0 );941 rem= CFFactory::basic (0L); 942 942 delete first; 943 943 } … … 946 946 } 947 947 else 948 rem = CFFactory::basic( 0 );948 rem = CFFactory::basic( 0L ); 949 949 } 950 950 else … … 1182 1182 { 1183 1183 delete this; 1184 return CFFactory::basic( 0 );1184 return CFFactory::basic( 0L ); 1185 1185 } 1186 1186 else 1187 1187 { 1188 1188 decRefCount(); 1189 return CFFactory::basic( 0 );1189 return CFFactory::basic( 0L ); 1190 1190 } 1191 1191 } … … 1196 1196 if ( getRefCount() <= 1 ) 1197 1197 { 1198 mulTermList( firstTerm, c, 0 );1198 mulTermList( firstTerm, c, 0L ); 1199 1199 return this; 1200 1200 } … … 1244 1244 { 1245 1245 delete this; 1246 return CFFactory::basic( 0 );1246 return CFFactory::basic( 0L ); 1247 1247 } 1248 1248 else 1249 1249 { 1250 1250 decRefCount(); 1251 return CFFactory::basic( 0 );1251 return CFFactory::basic( 0L ); 1252 1252 } 1253 1253 } … … 1270 1270 { 1271 1271 delete this; 1272 return CFFactory::basic( 0 );1272 return CFFactory::basic( 0L ); 1273 1273 } 1274 1274 } … … 1289 1289 { 1290 1290 delete first; 1291 return CFFactory::basic( 0 );1291 return CFFactory::basic( 0L ); 1292 1292 } 1293 1293 } … … 1338 1338 { 1339 1339 delete this; 1340 return CFFactory::basic( 0 );1340 return CFFactory::basic( 0L ); 1341 1341 } 1342 1342 else 1343 1343 { 1344 1344 decRefCount(); 1345 return CFFactory::basic( 0 );1345 return CFFactory::basic( 0L ); 1346 1346 } 1347 1347 } … … 1365 1365 { 1366 1366 delete this; 1367 return CFFactory::basic( 0 );1367 return CFFactory::basic( 0L ); 1368 1368 } 1369 1369 } … … 1384 1384 { 1385 1385 delete first; 1386 return CFFactory::basic( 0 );1386 return CFFactory::basic( 0L ); 1387 1387 } 1388 1388 } … … 1416 1416 { 1417 1417 delete this; 1418 return CFFactory::basic( 0 );1418 return CFFactory::basic( 0L ); 1419 1419 } 1420 1420 else 1421 1421 { 1422 1422 decRefCount(); 1423 return CFFactory::basic( 0 );1423 return CFFactory::basic( 0L ); 1424 1424 } 1425 1425 } … … 1442 1442 { 1443 1443 delete this; 1444 return CFFactory::basic( 0 );1444 return CFFactory::basic( 0L ); 1445 1445 } 1446 1446 } … … 1461 1461 { 1462 1462 delete first; 1463 return CFFactory::basic( 0 );1463 return CFFactory::basic( 0L ); 1464 1464 } 1465 1465 } … … 1500 1500 { 1501 1501 delete this; 1502 return CFFactory::basic( 0 );1502 return CFFactory::basic( 0L ); 1503 1503 } 1504 1504 else 1505 1505 { 1506 1506 decRefCount(); 1507 return CFFactory::basic( 0 );1507 return CFFactory::basic( 0L ); 1508 1508 } 1509 1509 } … … 1518 1518 { 1519 1519 delete this; 1520 return CFFactory::basic (0 );1520 return CFFactory::basic (0L); 1521 1521 } 1522 1522 if ( firstTerm && firstTerm->exp != 0 ) … … 1531 1531 { 1532 1532 delete this; 1533 return CFFactory::basic( 0 );1533 return CFFactory::basic( 0L ); 1534 1534 } 1535 1535 } … … 1542 1542 { 1543 1543 delete this; 1544 return CFFactory::basic (0 );1544 return CFFactory::basic (0L); 1545 1545 } 1546 1546 if (fail) 1547 1547 { 1548 1548 delete first; 1549 return CFFactory::basic (0 );1549 return CFFactory::basic (0L); 1550 1550 } 1551 1551 if ( first && first->exp != 0 ) … … 1560 1560 { 1561 1561 delete first; 1562 return CFFactory::basic( 0 );1562 return CFFactory::basic( 0L ); 1563 1563 } 1564 1564 } … … 1577 1577 ASSERT( ! c.isZero(), "divide by zero!" ); 1578 1578 if ( deleteObject() ) delete this; 1579 return CFFactory::basic( 0 );1579 return CFFactory::basic( 0L ); 1580 1580 } 1581 1581 … … 1595 1595 { 1596 1596 delete this; 1597 return CFFactory::basic( 0 );1597 return CFFactory::basic( 0L ); 1598 1598 } 1599 1599 else 1600 1600 { 1601 1601 decRefCount(); 1602 return CFFactory::basic( 0 );1602 return CFFactory::basic( 0L ); 1603 1603 } 1604 1604 } … … 1619 1619 { 1620 1620 delete this; 1621 return CFFactory::basic( 0 );1621 return CFFactory::basic( 0L ); 1622 1622 } 1623 1623 } … … 1638 1638 { 1639 1639 delete first; 1640 return CFFactory::basic( 0 );1640 return CFFactory::basic( 0L ); 1641 1641 } 1642 1642 } … … 1651 1651 quot = copyObject(); 1652 1652 quot = quot->dividecoeff( cc, invert ); 1653 rem = CFFactory::basic( 0 );1653 rem = CFFactory::basic( 0L ); 1654 1654 } 1655 1655 else if ( invert ) … … 1659 1659 else 1660 1660 rem = cc->copyObject(); 1661 quot = CFFactory::basic( 0 );1661 quot = CFFactory::basic( 0L ); 1662 1662 } 1663 1663 else … … 1676 1676 quot = new InternalPoly( quotfirst, quotlast, var ); 1677 1677 else 1678 quot = CFFactory::basic( 0 );1679 rem = CFFactory::basic( 0 );1678 quot = CFFactory::basic( 0L ); 1679 rem = CFFactory::basic( 0L ); 1680 1680 } 1681 1681 } … … 1688 1688 quot = copyObject(); 1689 1689 quot = quot->dividecoeff( cc, invert ); 1690 rem = CFFactory::basic( 0 );1690 rem = CFFactory::basic( 0L ); 1691 1691 return true; 1692 1692 } … … 1697 1697 else 1698 1698 rem = cc->copyObject(); 1699 quot = CFFactory::basic( 0 );1699 quot = CFFactory::basic( 0L ); 1700 1700 return true; 1701 1701 } … … 1737 1737 quot = new InternalPoly( quotfirst, quotcursor, var ); 1738 1738 else 1739 quot = CFFactory::basic( 0 );1740 rem = CFFactory::basic( 0 );1739 quot = CFFactory::basic( 0L ); 1740 rem = CFFactory::basic( 0L ); 1741 1741 } 1742 1742 else … … 1756 1756 if (fail) 1757 1757 return false; 1758 rem = CFFactory::basic( 0 );1758 rem = CFFactory::basic( 0L ); 1759 1759 return true; 1760 1760 } … … 1765 1765 else 1766 1766 rem = cc->copyObject(); 1767 quot = CFFactory::basic( 0 );1767 quot = CFFactory::basic( 0L ); 1768 1768 return true; 1769 1769 } … … 1810 1810 quot = new InternalPoly( quotfirst, quotcursor, var ); 1811 1811 else 1812 quot = CFFactory::basic( 0 );1813 rem = CFFactory::basic( 0 );1812 quot = CFFactory::basic( 0L ); 1813 rem = CFFactory::basic( 0L ); 1814 1814 } 1815 1815 else -
factory/int_pp.cc
r1bc7201 rc879ee 243 243 if ( c == this ) { 244 244 if ( deleteObject() ) delete this; 245 return CFFactory::basic( 1 );245 return CFFactory::basic( 1L ); 246 246 } 247 247 if ( getRefCount() > 1 ) { … … 276 276 { 277 277 if ( deleteObject() ) delete this; 278 return CFFactory::basic( 0 );278 return CFFactory::basic( 0L ); 279 279 } 280 280 … … 283 283 { 284 284 if ( deleteObject() ) delete this; 285 return CFFactory::basic( 0 );285 return CFFactory::basic( 0L ); 286 286 } 287 287 … … 290 290 { 291 291 if ( c == this ) { 292 quot = CFFactory::basic( 1 );293 rem = CFFactory::basic( 0 );292 quot = CFFactory::basic( 1L ); 293 rem = CFFactory::basic( 0L ); 294 294 } 295 295 else { … … 304 304 mpz_mod( b, b, primepow ); 305 305 quot = new InternalPrimePower( b ); 306 rem = CFFactory::basic( 0 );306 rem = CFFactory::basic( 0L ); 307 307 } 308 308 } … … 394 394 } 395 395 396 int 396 long 397 397 InternalPrimePower::intval () const 398 398 { 399 return (int)mpz_get_si( thempi );399 return mpz_get_si( thempi ); 400 400 } 401 401 -
factory/int_pp.h
r1bc7201 rc879ee 88 88 bool divremcoefft( InternalCF*, InternalCF*&, InternalCF*&, bool ); 89 89 90 intintval() const;90 long intval() const; 91 91 92 92 int intmod( int p ) const; -
factory/int_rat.cc
r1bc7201 rc879ee 29 29 } 30 30 31 static long intgcd( long a, long b ) 32 { 33 if ( a < 0 ) a = -a; 34 if ( b < 0 ) b = -b; 35 36 long c; 37 38 while ( b != 0 ) 39 { 40 c = a % b; 41 a = b; 42 b = c; 43 } 44 return a; 45 } 46 31 47 32 48 InternalRational::InternalRational() … … 53 69 { 54 70 int g = intgcd( n, d ); 71 if ( d < 0 ) 72 { 73 mpz_init_set_si( _num, -n / g ); 74 mpz_init_set_si( _den, -d / g ); 75 } 76 else 77 { 78 mpz_init_set_si( _num, n / g ); 79 mpz_init_set_si( _den, d / g ); 80 } 81 } 82 } 83 84 InternalRational::InternalRational( const long i ) 85 { 86 mpz_init_set_si( _num, i ); 87 mpz_init_set_si( _den, 1 ); 88 } 89 90 InternalRational::InternalRational( const long n, const long d ) 91 { 92 ASSERT( d != 0, "divide by zero" ); 93 if ( n == 0 ) 94 { 95 mpz_init_set_si( _num, 0 ); 96 mpz_init_set_si( _den, 1 ); 97 } 98 else 99 { 100 long g = intgcd( n, d ); 55 101 if ( d < 0 ) 56 102 { … … 378 424 { 379 425 if ( deleteObject() ) delete this; 380 return CFFactory::basic( 1 );426 return CFFactory::basic( 1L ); 381 427 } 382 428 else … … 449 495 { 450 496 if ( deleteObject() ) delete this; 451 return CFFactory::basic( 0 );497 return CFFactory::basic( 0L ); 452 498 } 453 499 … … 456 502 quot = copyObject(); 457 503 quot = quot->dividesame( c ); 458 rem = CFFactory::basic( 0 );504 rem = CFFactory::basic( 0L ); 459 505 } 460 506 … … 528 574 if ( ::is_imm( c ) ) 529 575 { 530 intcc = imm2int( c );576 long cc = imm2int( c ); 531 577 if ( cc == 0 ) 532 578 return this; … … 565 611 if ( ::is_imm( c ) ) 566 612 { 567 intcc = imm2int( c );613 long cc = imm2int( c ); 568 614 if ( cc == 0 ) 569 615 { … … 622 668 if ( ::is_imm( c ) ) 623 669 { 624 intcc = imm2int( c );670 long cc = imm2int( c ); 625 671 if ( cc == 0 ) 626 672 { 627 673 if ( deleteObject() ) delete this; 628 return CFFactory::basic( 0 );674 return CFFactory::basic( 0L ); 629 675 } 630 676 mpz_init_set_si( n, cc ); … … 675 721 if ( ::is_imm( c ) ) 676 722 { 677 intcc = imm2int( c );723 long cc = imm2int( c ); 678 724 ASSERT( c != 0 || invert, "divide by zero" ); 679 725 if ( cc == 0 ) … … 681 727 // => invert 682 728 if ( deleteObject() ) delete this; 683 return CFFactory::basic( 0 );729 return CFFactory::basic( 0L ); 684 730 } 685 731 if ( invert ) … … 764 810 ASSERT( invert || ! ::is_imm( c ) || imm2int( c ) != 0, "divide by zero" ); 765 811 if ( deleteObject() ) delete this; 766 return CFFactory::basic( 0 );812 return CFFactory::basic( 0L ); 767 813 } 768 814 … … 771 817 quot = copyObject(); 772 818 quot = quot->dividecoeff( c, invert ); 773 rem = CFFactory::basic( 0 );819 rem = CFFactory::basic( 0L ); 774 820 } 775 821 … … 851 897 852 898 853 int InternalRational::intval() const 854 { 899 long InternalRational::intval() const 900 { 901 855 902 ASSERT( mpz_cmp_si( _den, 1 ) == 0, "illegal operation" ); 856 return (int)mpz_get_si( _num ); 903 return mpz_get_si( _num ); 904 857 905 } 858 906 -
factory/int_rat.h
r1bc7201 rc879ee 40 40 InternalRational( const int i ); 41 41 InternalRational( const int n, const int d ); 42 InternalRational( const long i ); 43 InternalRational( const long n, const long d ); 42 44 InternalRational( const char * str ); 43 45 InternalRational( const mpz_ptr ); … … 90 92 InternalCF * bextgcdcoeff ( InternalCF *, CanonicalForm &, CanonicalForm & ); 91 93 92 intintval() const;94 long intval() const; 93 95 94 96 int sign() const; -
libpolys/coeffs/longrat.cc
r1bc7201 rc879ee 267 267 { 268 268 mpz_t dummy; 269 mpz_init_set( dummy,n->z ); 270 term = make_cf( dummy ); 269 long lz=mpz_get_si(n->z); 270 if (mpz_cmp_si(n->z,lz)==0) term=lz; 271 else 272 { 273 mpz_init_set( dummy,n->z ); 274 term = make_cf( dummy ); 275 } 271 276 } 272 277 else … … 287 292 if (n.isImm()) 288 293 { 294 long lz=n.intval(); 295 int iz=(int)lz; 296 if ((long)iz==lz) 297 { 298 return nlInit(n.intval(),r); 299 } 300 else return nlRInit(lz); 289 301 return nlInit(n.intval(),r); 290 302 } -
libpolys/polys/clapconv.cc
r1bc7201 rc879ee 245 245 { 246 246 if ( f.isImm() ) 247 return n_Init( f.intval(), r->cf->extRing->cf); 247 { 248 long longf=f.intval(); 249 int intf=(int) longf; 250 if((long)intf==longf) 251 { 252 assume (r->cf->extRing != NULL); 253 return n_Init(f.intval(),r->cf->extRing->cf); 254 } 255 else return nlRInit( longf ); 256 } 248 257 else 249 258 {
Note: See TracChangeset
for help on using the changeset viewer.