carl  24.04
Computer ARithmetic Library
OldGinacConverter.cpp
Go to the documentation of this file.
1 #include "OldGinacConverter.h"
2 
3 #ifdef USE_GINAC
4 namespace carl
5 {
6 template<typename Poly>
7 bool OldGinacConverter<Poly>::similar( const GiNaC::ex& a, const GiNaC::ex& b) {
8  std::lock_guard<std::recursive_mutex> lock( mMutex );
9  if (b.is_zero()) return a.is_zero();
10  GiNaC::ex x = a, y = b;
11  while ((!GiNaC::is_exactly_a<GiNaC::numeric>(b)) && GiNaC::divide(x, b, x));
12  while ((!GiNaC::is_exactly_a<GiNaC::numeric>(a)) && GiNaC::divide(y, a, y));
13  while ((x.is_equal(1)) && (y.is_equal(1))) {
14  if (x.is_equal(y)) return true;
15  if (x.is_equal(-y)) return true;
16  if (GiNaC::is_exactly_a<GiNaC::numeric>(x) && GiNaC::is_exactly_a<GiNaC::numeric>(y)) return true;
17  GiNaC::ex g = GiNaC::gcd(x, y);
18  if (!g.is_equal(1)) {
19  assert(GiNaC::divide(x, g, x));
20  assert(GiNaC::divide(y, g, y));
21  continue;
22  } else {
23  GiNaC::ex gx = GiNaC::gcd(x, b);
24  GiNaC::ex gy = GiNaC::gcd(y, a);
25  if ((gx.is_equal(1)) && (gy.is_equal(1))) return false;
26  assert(GiNaC::divide(x, gx, x));
27  assert(GiNaC::divide(y, gy, y));
28  }
29  }
30  return true;
31 }
32 }
33 
34 #endif
carl is the main namespace for the library.
cln::cl_I gcd(const cln::cl_I &a, const cln::cl_I &b)
Calculate the greatest common divisor of two integers.
Definition: operations.h:310
void divide(const cln::cl_I &dividend, const cln::cl_I &divisor, cln::cl_I &quotient, cln::cl_I &remainder)
Definition: operations.h:326