 Timestamp:
 Dec 17, 1997, 3:09:05 PM (26 years ago)
 Branches:
 (u'spielwiese', 'd1b01e9d51ade4b46b745d3bada5c5f3696be3a8')
 Children:
 818a5178f956c11702e9d2e0ebbf9922b7d13967
 Parents:
 55a5e8daa96ab4a7ccbc1691628558adb1f15196
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

factory/int_poly.cc
r55a5e8d r2085fc 1 1 /* emacs edit mode for this file is * C++ * */ 2 /* $Id: int_poly.cc,v 1. 7 19971209 09:05:44schmidt Exp $ */2 /* $Id: int_poly.cc,v 1.8 19971217 14:09:05 schmidt Exp $ */ 3 3 4 4 #include <config.h> … … 232 232 } 233 233 234 int235 InternalPoly::comparesame ( InternalCF* acoeff )236 {237 InternalPoly* apoly = (InternalPoly*)acoeff;238 if ( this == apoly )239 return 0;240 else {241 termList cur1 = firstTerm;242 termList cur2 = apoly>firstTerm;243 for ( ; cur1 && cur2; cur1 = cur1>next, cur2 = cur2>next )244 if ( ( cur1>exp != cur2>exp )  ( cur1>coeff != cur2>coeff ) )245 if ( cur1>exp > cur2>exp )246 return 1;247 else if ( cur1>exp < cur2>exp )248 return 1;249 else if ( cur1>coeff > cur2>coeff )250 return 1;251 else252 return 1;253 return cur1 != cur2;254 }255 }256 257 234 InternalCF* 258 235 InternalPoly::addsame( InternalCF* aCoeff ) … … 628 605 } 629 606 607 //{{{ int InternalPoly::comparesame, comparecoeff ( InternalCF * acoeff ) 608 //{{{ docu 609 // 610 // comparesame(), comparecoeff()  compare with an 611 // InternalPoly. 612 // 613 // comparecoeff() always returns 1 since CO is defined to be 614 // larger than anything which is a coefficient w.r.t. CO. 615 // 616 // comparesame() compares the coefficient vectors of f=CO and 617 // g=acoeff w.r.t to a lexicographic order in the following way: 618 // f < g iff there exists an 0 <= i <= max(deg(f),deg(g)) s.t. 619 // i) f[j] = g[j] for all i < j <= max(deg(f),deg(g)) and 620 // ii) g[i] occurs in g (i.e. is not equal to zero) and 621 // f[i] does not occur in f or f[i] < g[i] if f[i] occurs 622 // where f[i] denotes the coefficient to the power x^i of f. 623 // 624 // As usual, comparesame() returns 1 if CO is larger than c, 0 if 625 // CO equals c, and 1 if CO is less than c. However, this 626 // function is optimized to test on equality since this is its 627 // most important and frequent usage. 628 // 629 // See the respective `CanonicalForm'methods for an explanation 630 // why we define such a strange (but total) ordering on 631 // polynomials. 632 // 633 //}}} 630 634 int 631 InternalPoly::comparecoeff ( InternalCF* ) 635 InternalPoly::comparesame ( InternalCF * acoeff ) 636 { 637 ASSERT( ! ::is_imm( acoeff ) && acoeff>level() > LEVELBASE, "incompatible base coefficients" ); 638 InternalPoly* apoly = (InternalPoly*)acoeff; 639 // check on triviality 640 if ( this == apoly ) 641 return 0; 642 else { 643 termList cursor1 = firstTerm; 644 termList cursor2 = apoly>firstTerm; 645 for ( ; cursor1 && cursor2; cursor1 = cursor1>next, cursor2 = cursor2>next ) 646 // we test on inequality of coefficients at this 647 // point instead of testing on "less than" at the 648 // last `else' in the enclosed `if' statement since a 649 // test on inequaltiy in general is cheaper 650 if ( (cursor1>exp != cursor2>exp)  (cursor1>coeff != cursor2>coeff) ) 651 if ( cursor1>exp > cursor2>exp ) 652 return 1; 653 else if ( cursor1>exp < cursor2>exp ) 654 return 1; 655 else if ( cursor1>coeff > cursor2>coeff ) 656 return 1; 657 else 658 return 1; 659 // check trailing terms 660 if ( cursor1 == cursor2 ) 661 return 0; 662 else if ( cursor1 != 0 ) 663 return 1; 664 else 665 return 1; 666 } 667 } 668 669 int 670 InternalPoly::comparecoeff ( InternalCF * ) 632 671 { 633 672 return 1; 634 673 } 674 //}}} 635 675 636 676 InternalCF*
Note: See TracChangeset
for help on using the changeset viewer.