Skip to content

Commit

Permalink
Explicitly check if a poly is 0, since divides() does not do it
Browse files Browse the repository at this point in the history
  • Loading branch information
benruijl committed Jun 17, 2015
1 parent 0785f9a commit a03f78d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sources/polygcd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,7 @@ const poly polygcd::gcd (const poly &a, const poly &b) {
}

for (unsigned int i = 0; i < bracketsorted.size(); i++) {
if (!poly::divides(res,bracketsorted[i])) {
if (res.is_zero() || !poly::divides(res,bracketsorted[i])) {
// if we can filter out more variables, call gcd again
if (bracketsorted[i].all_variables().size() < x.size())
res = gcd(bracketsorted[i],res);
Expand All @@ -1535,7 +1535,7 @@ const poly polygcd::gcd (const poly &a, const poly &b) {
}
}

if (!poly::divides(res,ppa) || !poly::divides(res,ppb)) {
if (res.is_zero() || !poly::divides(res,ppa) || !poly::divides(res,ppb)) {
MesPrint("Bad gcd found.");
std::cout << "Bad gcd:" << res << " for " << ppa << " " << ppb << std::endl;
Terminate(1);
Expand Down

0 comments on commit a03f78d

Please sign in to comment.