X-Git-Url: https://ginac.de/ginac.git//ginac.git?a=blobdiff_plain;f=ginac%2Fpolynomial%2Fmgcd.cpp;h=932ae0552217f82ea9d48ff6c5c87aa7b1faa43d;hb=1be7026a705dfefedcd838e6b60795ca6d469bf9;hp=7500805e4129cdf008226b50702c3ed39465fbf8;hpb=eccdca0011fc44bc14cfcb7ffd82dbcb653e19a5;p=ginac.git diff --git a/ginac/polynomial/mgcd.cpp b/ginac/polynomial/mgcd.cpp index 7500805e..932ae055 100644 --- a/ginac/polynomial/mgcd.cpp +++ b/ginac/polynomial/mgcd.cpp @@ -3,7 +3,7 @@ * Chinese remainder algorithm. */ /* - * GiNaC Copyright (C) 1999-2010 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2018 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -40,6 +40,7 @@ static cln::cl_I extract_integer_content(ex& Apr, const ex& A) { static const cln::cl_I n1(1); const numeric icont_ = A.integer_content(); + GINAC_ASSERT(cln::instanceof(icont_.to_cl_N(), cln::cl_RA_ring)); if (cln::instanceof(icont_.to_cl_N(), cln::cl_I_ring)) { const cln::cl_I icont = cln::the(icont_.to_cl_N()); if (icont != 1) { @@ -49,14 +50,12 @@ static cln::cl_I extract_integer_content(ex& Apr, const ex& A) Apr = A; return n1; } - } - if (cln::instanceof(icont_.to_cl_N(), cln::cl_RA_ring)) { + } else { Apr = (A/icont_).expand(); - // A is a polynomail over rationals, so GCD is defined + // A is a polynomial over rationals, so GCD is defined // up to arbitrary rational number. return n1; } - GINAC_ASSERT(NULL == "expected polynomial over integers or rationals"); } ex chinrem_gcd(const ex& A_, const ex& B_, const exvector& vars) @@ -70,7 +69,6 @@ ex chinrem_gcd(const ex& A_, const ex& B_, const exvector& vars) const cln::cl_I b_lc = integer_lcoeff(B, vars); const cln::cl_I g_lc = cln::gcd(a_lc, b_lc); - const ex& x(vars.back()); exp_vector_t n = std::min(degree_vector(A, vars), degree_vector(B, vars)); const int nTot = std::accumulate(n.begin(), n.end(), 0); const cln::cl_I A_max_coeff = to_cl_I(A.max_coefficient()); @@ -101,7 +99,7 @@ ex chinrem_gcd(const ex& A_, const ex& B_, const exvector& vars) Cp = (Cp*numeric(nlc)).expand().smod(pnum); exp_vector_t cp_deg = degree_vector(Cp, vars); if (zerop(cp_deg)) - return numeric(g_lc); + return numeric(c); if (zerop(q)) { H = Cp; n = cp_deg;