[GiNaC-devel] [PATCH 1/2] extract_integer_content: check for rational numbers properly.
Alexei Sheplyakov
alexei.sheplyakov at gmail.com
Fri Dec 3 22:49:27 CET 2010
Commit 3d09388a (titled as `[bugfix] chinrem_gcd: handle polynomials over
rationals properly.') broke extract_integer_content: now it always returns 1.
The check for rational `integer_contnent' introduced by that commit is wrong
(since integers is a subset of rationals). Rewrite the check proprerly.
---
ginac/polynomial/mgcd.cpp | 20 +++++++++++---------
1 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/ginac/polynomial/mgcd.cpp b/ginac/polynomial/mgcd.cpp
index 5b9da12..7500805 100644
--- a/ginac/polynomial/mgcd.cpp
+++ b/ginac/polynomial/mgcd.cpp
@@ -40,21 +40,23 @@ 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();
+ if (cln::instanceof(icont_.to_cl_N(), cln::cl_I_ring)) {
+ const cln::cl_I icont = cln::the<cln::cl_I>(icont_.to_cl_N());
+ if (icont != 1) {
+ Apr = (A/icont_).expand();
+ return icont;
+ } else {
+ Apr = A;
+ return n1;
+ }
+ }
if (cln::instanceof(icont_.to_cl_N(), cln::cl_RA_ring)) {
Apr = (A/icont_).expand();
// A is a polynomail over rationals, so GCD is defined
// up to arbitrary rational number.
return n1;
}
- GINAC_ASSERT(cln::instanceof(icont_.to_cl_N(), cln::cl_I_ring));
- const cln::cl_I icont = cln::the<cln::cl_I>(icont_.to_cl_N());
- if (icont != 1) {
- Apr = (A/icont_).expand();
- return icont;
- } else {
- Apr = A;
- return n1;
- }
+ GINAC_ASSERT(NULL == "expected polynomial over integers or rationals");
}
ex chinrem_gcd(const ex& A_, const ex& B_, const exvector& vars)
--
1.7.2.3
More information about the GiNaC-devel
mailing list