1 /** @file pgcd_relatively_prime_bug.cpp
3 * A program exposing historical bug in the pgcd() function.
10 using namespace GiNaC;
12 int main(int argc, char** argv)
14 cout << "Checking for pgcd() bug regarding relatively prime polynomials: " << flush;
17 reader.get_syms().insert(make_pair(string("q"), q));
19 ex t = reader("-E20^16*E4^8*E5^8*E1^16*q^4"
20 "-(E10^24-E20^8*E5^16)*E4^16*E1^8"
21 "+E2^24*E20^16*E5^8*q^4");
22 ex g = gcd(t.expand(), t.diff(q).expand()) - 1;
24 cout << " oops!" << endl <<
25 "** Error: should be 0, got " << g << endl << flush;
26 throw std::logic_error("gcd was miscalculated");
28 cout << "not found" << endl << flush;