 Timestamp:
 Mar 17, 1998, 4:59:42 PM (26 years ago)
 Branches:
 (u'spielwiese', 'd1b01e9d51ade4b46b745d3bada5c5f3696be3a8')
 Children:
 e0fb8d31ff69374db7f865baedfda3e614804382
 Parents:
 bb17e813fdec9082fa78763093e18795ea0fdbb4
 Location:
 factory
 Files:

 1 added
 5 edited
Legend:
 Unmodified
 Added
 Removed

factory/GNUmakefile.in
rbb17e8 rfc732a9 1 1 # @configure_input@ 2 # $Id: GNUmakefile.in,v 1.3 1 19980311 18:35:31schmidt Exp $2 # $Id: GNUmakefile.in,v 1.32 19980317 15:59:42 schmidt Exp $ 3 3 4 4 # … … 163 163 int_cf.cc \ 164 164 int_int.cc \ 165 int_intdiv.cc \ 165 166 int_poly.cc \ 166 167 int_pp.cc \ 
factory/int_int.cc
rbb17e8 rfc732a9 1 1 /* emacs edit mode for this file is * C++ * */ 2 /* $Id: int_int.cc,v 1.1 1 19980122 10:54:15schmidt Exp $ */2 /* $Id: int_int.cc,v 1.12 19980317 15:56:04 schmidt Exp $ */ 3 3 4 4 #include <config.h> 5 5 6 #include "assert.h" 7 8 #include "cf_defs.h" 9 #include "cf_globals.h" 6 #include "imm.h" 10 7 #include "int_int.h" 11 8 #include "int_rat.h" 12 #include "imm.h" 9 #include "cf_gmp.h" 10 #include "gmpext.h" 13 11 #include "canonicalform.h" 14 #include "gmpext.h" 15 12 16 13 InternalInteger::InternalInteger() 17 14 { … … 185 182 return this; 186 183 } 187 }188 189 InternalCF* InternalInteger::dividesame( InternalCF * c )190 {191 return divsame( c );192 }193 194 InternalCF* InternalInteger::divsame( InternalCF * c )195 {196 if ( c == this ) {197 if ( deleteObject() ) delete this;198 return CFFactory::basic( 1 );199 }200 if ( cf_glob_switches.isOn( SW_RATIONAL ) ) {201 MP_INT n, d;202 mpz_init_set( &n, &thempi );203 mpz_init_set( &d, &MPI( c ) );204 if ( deleteObject() ) delete this;205 InternalRational * result = new InternalRational( n, d );206 return result>normalize_myself();207 }208 if ( getRefCount() > 1 ) {209 decRefCount();210 MP_INT quot;211 MP_INT rem;212 int signmpi = mpz_cmp_si( &thempi, 0 );213 int signc = mpz_cmp_si( &MPI( c ), 0 );214 if ( signmpi < 0 )215 mpz_neg( &thempi, &thempi );216 if ( signc < 0 )217 mpz_neg( &MPI( c ), &MPI( c ) );218 mpz_init( " ); mpz_init( &rem );219 mpz_divmod( ", &rem, &thempi, &MPI( c ) );220 if ( signmpi < 0 )221 mpz_neg( &thempi, &thempi );222 if ( signc < 0 )223 mpz_neg( &MPI( c ), &MPI( c ) );224 if ( signmpi < 0 && signc < 0 ) {225 if ( mpz_cmp_si( &rem, 0 ) != 0 )226 mpz_add_ui( ", ", 1 );227 }228 else if ( signc < 0 )229 mpz_neg( ", " );230 else if ( signmpi < 0 ) {231 mpz_neg( ", " );232 if ( mpz_cmp_si( &rem, 0 ) != 0 )233 mpz_sub_ui( ", ", 1 );234 }235 mpz_clear( &rem );236 if ( mpz_is_imm( " ) ) {237 InternalCF * res = int2imm( mpz_get_si( " ) );238 mpz_clear( " );239 return res;240 }241 else242 return new InternalInteger( quot );243 }244 else {245 MP_INT rem;246 mpz_init( &rem );247 int signmpi = mpz_cmp_si( &thempi, 0 );248 int signc = mpz_cmp_si( &MPI( c ), 0 );249 if ( signmpi < 0 )250 mpz_neg( &thempi, &thempi );251 if ( signc < 0 )252 mpz_neg( &MPI( c ), &MPI( c ) );253 mpz_divmod( &thempi, &rem, &thempi, &MPI( c ) );254 if ( signc < 0 )255 mpz_neg( &MPI( c ), &MPI( c ) );256 if ( signmpi < 0 && signc < 0 ) {257 if ( mpz_cmp_si( &rem, 0 ) != 0 )258 mpz_add_ui( &thempi, &thempi, 1 );259 }260 else if ( signc < 0 )261 mpz_neg( &thempi, &thempi );262 else if ( signmpi < 0 ) {263 mpz_neg( &thempi, &thempi );264 if ( mpz_cmp_si( &rem, 0 ) != 0 )265 mpz_sub_ui( &thempi, &thempi, 1 );266 }267 mpz_clear( &rem );268 if ( mpz_is_imm( &thempi ) ) {269 InternalCF * res = int2imm( mpz_get_si( &thempi ) );270 delete this;271 return res;272 }273 else274 return this;275 }276 }277 278 InternalCF* InternalInteger::modulosame ( InternalCF * c )279 {280 return modsame( c );281 }282 283 InternalCF* InternalInteger::modsame( InternalCF * c )284 {285 if ( cf_glob_switches.isOn( SW_RATIONAL )  c == this ) {286 if ( deleteObject() ) delete this;287 return CFFactory::basic( 0 );288 }289 if ( getRefCount() > 1 ) {290 decRefCount();291 MP_INT dummy;292 mpz_init( &dummy );293 int signmpi = mpz_cmp_si( &thempi, 0 );294 int signc = mpz_cmp_si( &MPI( c ), 0 );295 if ( signmpi < 0 )296 mpz_neg( &thempi, &thempi );297 if ( signc < 0 )298 mpz_neg( &MPI( c ), &MPI( c ) );299 mpz_mod( &dummy, &thempi, &MPI( c ) );300 if ( signmpi < 0 && mpz_cmp_si( &dummy, 0 ) != 0 ) {301 mpz_sub( &dummy, &MPI( c ), &dummy );302 }303 if ( signmpi < 0 )304 mpz_neg( &thempi, &thempi );305 if ( signc < 0 )306 mpz_neg( &MPI( c ), &MPI( c ) );307 if ( mpz_is_imm( &dummy ) ) {308 InternalCF * res = int2imm( mpz_get_si( &dummy ) );309 mpz_clear( &dummy );310 return res;311 }312 else313 return new InternalInteger( dummy );314 }315 else {316 int signmpi = mpz_cmp_si( &thempi, 0 );317 int signc = mpz_cmp_si( &MPI( c ), 0 );318 if ( signmpi < 0 )319 mpz_neg( &thempi, &thempi );320 if ( signc < 0 )321 mpz_neg( &MPI( c ), &MPI( c ) );322 mpz_mod( &thempi, &thempi, &MPI( c ) );323 if ( signmpi < 0 && mpz_cmp_si( &thempi, 0 ) != 0 ) {324 mpz_sub( &thempi, &MPI( c ), &thempi );325 }326 if ( signc < 0 )327 mpz_neg( &MPI( c ), &MPI( c ) );328 if ( mpz_is_imm( &thempi ) ) {329 InternalCF * res = int2imm( mpz_get_si( &thempi ) );330 delete this;331 return res;332 }333 else334 return this;335 }336 }337 338 void InternalInteger::divremsame( InternalCF * c, InternalCF*& quot, InternalCF*& rem )339 {340 if ( cf_glob_switches.isOn( SW_RATIONAL ) ) {341 quot = copyObject();342 quot = quot>dividesame( c );343 rem = CFFactory::basic( 0 );344 }345 else if ( c == this ) {346 quot = CFFactory::basic( 1 );347 rem = CFFactory::basic( 0 );348 }349 else {350 MP_INT q;351 MP_INT r;352 mpz_init( &q ); mpz_init( &r );353 int signmpi = mpz_cmp_si( &thempi, 0 );354 int signc = mpz_cmp_si( &MPI( c ), 0 );355 if ( signmpi < 0 )356 mpz_neg( &thempi, &thempi );357 if ( signc < 0 )358 mpz_neg( &MPI( c ), &MPI( c ) );359 mpz_divmod( &q, &r, &thempi, &MPI( c ) );360 if ( signmpi < 0 && mpz_cmp_si( &r, 0 ) != 0 ) {361 mpz_sub( &r, &MPI( c ), &r );362 }363 if ( signmpi < 0 )364 mpz_neg( &thempi, &thempi );365 if ( signc < 0 )366 mpz_neg( &MPI( c ), &MPI( c ) );367 if ( signmpi < 0 && signc < 0 ) {368 if ( mpz_cmp_si( &r, 0 ) != 0 )369 mpz_add_ui( &q, &q, 1 );370 }371 else if ( signc < 0 )372 mpz_neg( &q, &q );373 else if ( signmpi < 0 ) {374 mpz_neg( &q, &q );375 if ( mpz_cmp_si( &r, 0 ) != 0 )376 mpz_sub_ui( &q, &q, 1 );377 }378 if ( mpz_is_imm( &q ) )379 quot = int2imm( mpz_get_si( &q ) );380 else381 quot = new InternalInteger( q );382 if ( mpz_is_imm( &r ) )383 rem = int2imm( mpz_get_si( &r ) );384 else385 rem = new InternalInteger( r );386 }387 }388 389 bool InternalInteger::divremsamet( InternalCF* c, InternalCF*& quot, InternalCF*& rem )390 {391 divremsame( c, quot, rem );392 return true;393 184 } 394 185 … … 532 323 return this; 533 324 } 534 }535 536 InternalCF* InternalInteger::dividecoeff( InternalCF* c, bool invert )537 {538 return divcoeff( c, invert );539 }540 541 InternalCF* InternalInteger::divcoeff( InternalCF* c, bool invert )542 {543 ASSERT( invert  ! ::is_imm( c )  imm2int( c ) != 0, "divide by zero" );544 int cc = imm2int( c );545 if ( cf_glob_switches.isOn( SW_RATIONAL ) ) {546 MP_INT n, d;547 if ( invert ) {548 mpz_init_set_si( &n, cc );549 mpz_init_set( &d, &thempi );550 }551 else {552 mpz_init_set_si( &d, cc );553 mpz_init_set( &n, &thempi );554 }555 if ( deleteObject() ) delete this;556 InternalRational * result = new InternalRational( n, d );557 return result>normalize_myself();558 }559 ASSERT( ::is_imm( c ) == INTMARK, "incompatible base coefficients" );560 MP_INT quot;561 MP_INT rem;562 int signmpi = mpz_cmp_si( &thempi, 0 );563 int signc = cc;564 mpz_init( " ); mpz_init( &rem );565 if ( signmpi < 0 )566 mpz_neg( &thempi, &thempi );567 if ( signc < 0 )568 cc = cc;569 if ( invert ) {570 MP_INT ccc;571 mpz_init_set_si( &ccc, cc );572 mpz_divmod( ", &rem, &ccc, &thempi );573 mpz_clear( &ccc );574 if ( signmpi < 0 )575 mpz_neg( &thempi, &thempi );576 if ( signmpi < 0 && signc < 0 ) {577 if ( mpz_cmp_si( &rem, 0 ) != 0 )578 mpz_add_ui( ", ", 1 );579 }580 else if ( signmpi < 0 )581 mpz_neg( ", " );582 else if ( signc < 0 ) {583 mpz_neg( ", " );584 if ( mpz_cmp_si( &rem, 0 ) != 0 )585 mpz_sub_ui( ", ", 1 );586 }587 }588 else {589 mpz_divmod_ui( ", &rem, &thempi, cc );590 if ( signmpi < 0 )591 mpz_neg( &thempi, &thempi );592 if ( signmpi < 0 && signc < 0 ) {593 if ( mpz_cmp_si( &rem, 0 ) != 0 )594 mpz_add_ui( ", ", 1 );595 }596 else if ( signc < 0 )597 mpz_neg( ", " );598 else if ( signmpi < 0 ) {599 mpz_neg( ", " );600 if ( mpz_cmp_si( &rem, 0 ) != 0 )601 mpz_sub_ui( ", ", 1 );602 }603 }604 mpz_clear( &rem );605 if ( deleteObject() ) delete this;606 if ( mpz_is_imm( " ) ) {607 InternalCF * res = int2imm( mpz_get_si( " ) );608 mpz_clear( " );609 return res;610 }611 else612 return new InternalInteger( quot );613 }614 615 InternalCF* InternalInteger::modulocoeff( InternalCF * c, bool invert )616 {617 return modcoeff( c, invert );618 }619 620 InternalCF* InternalInteger::modcoeff( InternalCF* c, bool invert )621 {622 ASSERT( ::is_imm( c ) == INTMARK, "incompatible base coefficients" );623 if ( cf_glob_switches.isOn( SW_RATIONAL ) ) {624 // in rational mode remainder is zero625 if ( deleteObject() ) delete this;626 return CFFactory::basic( 0 );627 }628 int cc = imm2int( c );629 MP_INT rem;630 int signmpi = mpz_cmp_si( &thempi, 0 );631 int signc = cc;632 mpz_init( &rem );633 if ( signmpi < 0 )634 mpz_neg( &thempi, &thempi );635 if ( signc < 0 )636 cc = cc;637 if ( invert ) {638 MP_INT ccc;639 mpz_init_set_si( &ccc, cc );640 mpz_mod( &rem, &ccc, &thempi );641 mpz_clear( &ccc );642 if ( signc < 0 && mpz_cmp_si( &rem, 0 ) != 0 ) {643 mpz_sub( &rem, &thempi, &rem );644 }645 if ( signmpi < 0 )646 mpz_neg( &thempi, &thempi );647 }648 else {649 mpz_mod_ui( &rem, &thempi, cc );650 if ( signmpi < 0 && mpz_cmp_si( &rem, 0 ) != 0 ) {651 mpz_neg( &rem, &rem );652 mpz_add_ui( &rem, &rem, cc );653 }654 if ( signmpi < 0 )655 mpz_neg( &thempi, &thempi );656 }657 if ( deleteObject() ) delete this;658 if ( mpz_is_imm( &rem ) ) {659 InternalCF * res = int2imm( mpz_get_si( &rem ) );660 mpz_clear( &rem );661 return res;662 }663 else664 return new InternalInteger( rem );665 }666 667 void InternalInteger::divremcoeff( InternalCF* c, InternalCF*& quot, InternalCF*& rem, bool invert )668 {669 ASSERT( ::is_imm( c ) == INTMARK, "incompatible base coefficients" );670 671 if ( cf_glob_switches.isOn( SW_RATIONAL ) ) {672 quot = copyObject();673 quot = quot>dividecoeff( c, invert );674 rem = CFFactory::basic( 0 );675 return;676 }677 quot = copyObject();678 quot = quot>divcoeff( c, invert );679 rem = copyObject();680 rem = rem>modcoeff( c, invert );681 return;682 int cc = imm2int( c );683 MP_INT q, r;684 int signmpi = mpz_cmp_si( &thempi, 0 );685 int signc = cc;686 687 mpz_init( &q ); mpz_init( &r );688 if ( signmpi < 0 )689 mpz_neg( &thempi, &thempi );690 if ( signc < 0 )691 cc = cc;692 if ( invert ) {693 MP_INT ccc;694 mpz_init_set_si( &ccc, cc );695 mpz_divmod( &q, &r, &ccc, &thempi );696 mpz_clear( &ccc );697 if ( signc < 0 && signmpi < 0 ) {698 if ( mpz_cmp_si( &r, 0 ) != 0 ) {699 mpz_add_ui( &q, &q, 1 );700 mpz_sub( &r, &thempi, &r );701 }702 }703 else if ( signc < 0 ) {704 if ( mpz_cmp_si( &r, 0 ) != 0 ) {705 mpz_add_ui( &q, &q, 1 );706 mpz_neg( &q, &q );707 mpz_sub( &r, &thempi, &r );708 }709 }710 else if ( signmpi < 0 )711 mpz_neg( &q, &q );712 }713 else {714 mpz_divmod_ui( &q, &r, &thempi, cc );715 if ( signmpi < 0 && signc < 0 ) {716 if ( mpz_cmp_si( &r, 0 ) != 0 ) {717 mpz_add_ui( &q, &q, 1 );718 mpz_neg( &r, &r );719 mpz_add_ui( &r, &r, cc );720 }721 }722 else if ( signmpi < 0 ) {723 if ( mpz_cmp_si( &r, 0 ) != 0 ) {724 mpz_add_ui( &q, &q, 1 );725 mpz_neg( &q, &q );726 mpz_neg( &r, &r );727 mpz_add_ui( &r, &r, cc );728 }729 }730 else if ( signc < 0 )731 mpz_neg( &q, &q );732 }733 if ( signmpi < 0 )734 mpz_neg( &thempi, &thempi );735 if ( mpz_is_imm( &r ) ) {736 rem = int2imm( mpz_get_si( &r ) );737 mpz_clear( &r );738 }739 else740 rem = new InternalInteger( r );741 if ( mpz_is_imm( &q ) ) {742 quot = int2imm( mpz_get_si( &q ) );743 mpz_clear( &q );744 }745 else746 quot = new InternalInteger( q );747 }748 749 bool InternalInteger::divremcoefft( InternalCF* c, InternalCF*& quot, InternalCF*& rem, bool invert )750 {751 ASSERT( ::is_imm( c ) == INTMARK, "incompatible base coefficients" );752 divremcoeff( c, quot, rem, invert );753 return true;754 325 } 755 326 
factory/int_int.h
rbb17e8 rfc732a9 1 1 /* emacs edit mode for this file is * C++ * */ 2 /* $Id: int_int.h,v 1. 7 19980122 10:54:22schmidt Exp $ */2 /* $Id: int_int.h,v 1.8 19980317 15:56:18 schmidt Exp $ */ 3 3 4 4 #ifndef INCL_INT_INT_H … … 7 7 #include <config.h> 8 8 9 #include "cf_gmp.h"10 9 #ifndef NOSTREAMIO 11 10 #include <iostream.h> … … 15 14 16 15 #include "int_cf.h" 16 #include "cf_gmp.h" 17 #include "gmpext.h" 17 18 18 19 class InternalInteger : public InternalCF … … 20 21 private: 21 22 MP_INT thempi; 22 static int initialized; 23 static MP_INT & MPI( const InternalCF * const c ); 23 24 // auxilliary methods 25 inline InternalCF * normalizeMyself (); 26 inline InternalCF * uiNormalizeMyself (); 27 28 static inline InternalCF * normalizeMPI ( MP_INT & ); 29 static inline InternalCF * uiNormalizeMPI ( MP_INT & ); 30 31 static inline MP_INT & MPI ( const InternalCF * const c ); 32 24 33 public: 25 34 InternalInteger(); … … 95 104 }; 96 105 97 inline MP_INT & InternalInteger::MPI( const InternalCF * const c ) 106 //{{{ inline InternalCF * InternalInteger::normalizeMyself, uiNormalizeMyself () 107 //{{{ docu 108 // 109 // normalizeMyself(), uiNormalizeMyself()  normalize CO. 110 // 111 // If CO fits into an immediate integer, delete CO and return the 112 // immediate. Otherwise, return a pointer to CO. 113 // 114 // `uiNormalizeMyself()' is the same as `normalizeMyself()' 115 // except that CO is expected to be nonbegative. In this case, 116 // we may use `mpz_get_ui()' to convert the underlying mpi into 117 // an immediate which is slightly faster than the signed variant. 118 // 119 // Note: We do not mind reference counting at this point! CO is 120 // deleted unconditionally! 121 // 122 //}}} 123 inline InternalCF * 124 InternalInteger::normalizeMyself () 125 { 126 ASSERT( getRefCount() == 1, "internal error: must not delete CO" ); 127 128 if ( mpz_is_imm( &thempi ) ) { 129 InternalCF * result = int2imm( mpz_get_si( &thempi ) ); 130 delete this; 131 return result; 132 } else 133 return this; 134 } 135 136 inline InternalCF * 137 InternalInteger::uiNormalizeMyself () 138 { 139 ASSERT( getRefCount() == 1, "internal error: must not delete CO" ); 140 141 if ( mpz_is_imm( &thempi ) ) { 142 InternalCF * result = int2imm( mpz_get_ui( &thempi ) ); 143 delete this; 144 return result; 145 } else 146 return this; 147 } 148 //}}} 149 150 //{{{ static inline InternalCF * InternalInteger::normalizeMPI, uiNormalizeMPI ( MP_INT & aMpi ) 151 //{{{ docu 152 // 153 // normalizeMPI(), uiNormalizeMPI()  normalize a mpi. 154 // 155 // If `aMpi' fits into an immediate integer, clear `aMpi' and 156 // return the immediate. Otherwise, return a new 157 // `InternalInteger' with `aMpi' as underlying mpi. 158 // 159 // `uiNormalizeMPI()' is the same as `normalizeMPI()' except that 160 // `aMpi' is expected to be nonbegative. In this case, we may 161 // use `mpz_get_ui()' to convert `aMpi' into an immediate which 162 // is slightly faster than the signed variant. 163 // 164 //}}} 165 inline InternalCF * 166 InternalInteger::normalizeMPI ( MP_INT & aMpi ) 167 { 168 if ( mpz_is_imm( &aMpi ) ) { 169 InternalCF * result = int2imm( mpz_get_si( &aMpi ) ); 170 mpz_clear( &aMpi ); 171 return result; 172 } else 173 return new InternalInteger( aMpi ); 174 } 175 176 inline InternalCF * 177 InternalInteger::uiNormalizeMPI ( MP_INT & aMpi ) 178 { 179 if ( mpz_is_imm( &aMpi ) ) { 180 InternalCF * result = int2imm( mpz_get_ui( &aMpi ) ); 181 mpz_clear( &aMpi ); 182 return result; 183 } else 184 return new InternalInteger( aMpi ); 185 } 186 //}}} 187 188 //{{{ inline MP_INT & InternalInteger::MPI ( const InternalCF * const c ) 189 //{{{ docu 190 // 191 // MPI()  return underlying mpi of `c'. 192 // 193 // `c' is expected to be an `InternalInteger *'. `c's underlying 194 // mpi is returned. 195 // 196 //}}} 197 inline MP_INT & 198 InternalInteger::MPI ( const InternalCF * const c ) 98 199 { 99 200 return (((InternalInteger*)c)>thempi); 100 201 } 202 //}}} 101 203 102 204 #endif /* ! INCL_INT_INT_H */ 
factory/int_poly.cc
rbb17e8 rfc732a9 1 1 /* emacs edit mode for this file is * C++ * */ 2 /* $Id: int_poly.cc,v 1. 9 19971217 14:15:06schmidt Exp $ */2 /* $Id: int_poly.cc,v 1.10 19980317 15:56:31 schmidt Exp $ */ 3 3 4 4 #include <config.h> … … 828 828 829 829 InternalCF* 830 InternalPoly::dividecoeff( InternalCF* c, bool invert ) 831 { 832 return divcoeff( c, invert ); 830 InternalPoly::dividecoeff( InternalCF* cc, bool invert ) 831 { 832 CanonicalForm c( is_imm(cc) ? cc : cc>copyObject() ); 833 if ( inExtension() && getReduce( var ) && invert ) { 834 InternalCF * dummy; 835 dummy = this>invert(); 836 dummy = dummy>mulcoeff( cc ); 837 if ( getRefCount() == 1 ) { 838 delete this; 839 return dummy; 840 } 841 else { 842 decRefCount(); 843 return dummy; 844 } 845 } 846 if ( invert ) 847 if ( getRefCount() == 1 ) { 848 delete this; 849 return CFFactory::basic( 0 ); 850 } 851 else { 852 decRefCount(); 853 return CFFactory::basic( 0 ); 854 } 855 if ( c.isOne() ) 856 return this; 857 else { 858 if ( getRefCount() == 1 ) { 859 firstTerm = divideTermList( firstTerm, c, lastTerm ); 860 if ( firstTerm && firstTerm>exp != 0 ) 861 return this; 862 else if ( firstTerm ) { 863 InternalCF * res = firstTerm>coeff.getval(); 864 delete this; 865 return res; 866 } 867 else { 868 delete this; 869 return CFFactory::basic( 0 ); 870 } 871 } 872 else { 873 decRefCount(); 874 termList last, first = copyTermList( firstTerm, last ); 875 first = divideTermList( first, c, last ); 876 if ( first && first>exp != 0 ) 877 return new InternalPoly( first, last, var ); 878 else if ( first ) { 879 InternalCF * res = first>coeff.getval(); 880 delete first; 881 return res; 882 } 883 else { 884 delete first; 885 return CFFactory::basic( 0 ); 886 } 887 } 888 } 833 889 } 834 890 … … 980 1036 ASSERT( ! c.isZero(), "divide by zero!" ); 981 1037 termList quotlast, quotfirst = copyTermList( firstTerm, quotlast ); 982 quotfirst = div TermList( quotfirst, c, quotlast );1038 quotfirst = divideTermList( quotfirst, c, quotlast ); 983 1039 if ( quotfirst ) 984 1040 if ( quotfirst>exp == 0 ) { … … 1218 1274 1219 1275 termList 1220 InternalPoly::div TermList ( termList firstTerm, const CanonicalForm& coeff, termList& lastTerm )1276 InternalPoly::divideTermList ( termList firstTerm, const CanonicalForm& coeff, termList& lastTerm ) 1221 1277 { 1222 1278 termList theCursor = firstTerm; … … 1226 1282 while ( theCursor ) { 1227 1283 theCursor>coeff /= coeff; 1284 if ( theCursor>coeff.isZero() ) { 1285 if ( theCursor == firstTerm ) 1286 firstTerm = theCursor>next; 1287 else 1288 lastTerm>next = theCursor>next; 1289 dummy = theCursor; 1290 theCursor = theCursor>next; 1291 delete dummy; 1292 } 1293 else { 1294 lastTerm = theCursor; 1295 theCursor = theCursor>next; 1296 } 1297 } 1298 return firstTerm; 1299 } 1300 1301 termList 1302 InternalPoly::divTermList ( termList firstTerm, const CanonicalForm& coeff, termList& lastTerm ) 1303 { 1304 termList theCursor = firstTerm; 1305 lastTerm = 0; 1306 termList dummy; 1307 1308 while ( theCursor ) { 1309 theCursor>coeff.div( coeff ); 1228 1310 if ( theCursor>coeff.isZero() ) { 1229 1311 if ( theCursor == firstTerm ) 
factory/int_poly.h
rbb17e8 rfc732a9 1 1 /* emacs edit mode for this file is * C++ * */ 2 /* $Id: int_poly.h,v 1. 4 19971010 10:36:16 schmidt Exp $ */2 /* $Id: int_poly.h,v 1.5 19980317 15:56:46 schmidt Exp $ */ 3 3 4 4 #ifndef INCL_INT_POLY_H … … 44 44 static termList addTermList ( termList, termList, termList&, bool negate ); 45 45 static void mulTermList ( termList, const CanonicalForm& , const int ); 46 static termList divideTermList ( termList, const CanonicalForm&, termList& ); 46 47 static termList divTermList ( termList, const CanonicalForm&, termList& ); 47 48 static termList modTermList ( termList, const CanonicalForm&, termList& );
Note: See TracChangeset
for help on using the changeset viewer.