carl  24.04
Computer ARithmetic Library
ThomEncoding.tpp
Go to the documentation of this file.
1 /*
2  * File: ThomEncoding.tpp
3  * Author: tobias
4  *
5  * Created on 20. August 2016, 11:37
6  */
7 
8 #include "ThomEncoding.h"
9 
10 
11 #pragma once
12 
13 namespace carl {
14 
15 //*******************//
16 // COMPARISON //
17 //*******************//
18 
19 /*
20  * called by ThomEncoding::compare
21  * don't call directly
22  */
23 template<typename Number>
24 ThomComparisonResult ThomEncoding<Number>::compareDifferentPoly(const ThomEncoding<Number>& lhs, const ThomEncoding<Number>& rhs) {
25  using Polynomial = MultivariatePolynomial<Number>;
26 
27  std::list<Polynomial> der_rhs = der(rhs.polynomial(), rhs.main_var(), 0, rhs.polynomial().degree(rhs.main_var()));
28  SignCondition sc_lhs_on_der_rhs;
29  auto it_der_rhs = der_rhs.rbegin();
30  uint currLength = 1;
31  for( ; it_der_rhs != der_rhs.rend(); it_der_rhs++) {
32  sc_lhs_on_der_rhs.push_front(lhs.signOnPolynomial(*it_der_rhs));
33  if(rhs.mSc.size() < currLength) rhs.extendSignCondition();
34  SignCondition sc_rhs_curr = rhs.mSc.trailingPart(currLength);
35  if(sc_rhs_curr != sc_lhs_on_der_rhs) {
36  CARL_LOG_TRACE("carl.thom.compare", "comparing " << sc_lhs_on_der_rhs << " with " << sc_rhs_curr);
37  return SignCondition::compare(sc_lhs_on_der_rhs, sc_rhs_curr);
38  }
39 
40  currLength++;
41  }
42  // that means that lhs realized precisely the same signs on der_rhs as rhs itself -> then the encoded numbers must be equal
43  return EQUAL;
44 }
45 
46 } // namespace carl