*/
/*
- * GiNaC Copyright (C) 1999-2011 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2014 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
cl_modint_ring R;
unsigned int trials = 0;
unsigned int minfactors = 0;
- cl_I lc = lcoeff(prim) * the<cl_I>(ex_to<numeric>(cont).to_cl_N());
+
+ const numeric& cont_n = ex_to<numeric>(cont);
+ cl_I i_cont;
+ if (cont_n.is_integer()) {
+ i_cont = the<cl_I>(cont_n.to_cl_N());
+ } else {
+ // poly \in Q[x] => poly = q ipoly, ipoly \in Z[x], q \in Q
+ // factor(poly) \equiv q factor(ipoly)
+ i_cont = cl_I(1);
+ }
+ cl_I lc = lcoeff(prim)*i_cont;
upvec factors;
while ( trials < 2 ) {
umodpoly modpoly;
return result;
}
if ( is_a<symbol>(e) || is_a<add>(e) ) {
- result.append(1);
- result.append(e);
+ ex icont(e.integer_content());
+ result.append(icont);
+ result.append(e/icont);
return result;
}
if ( is_a<mul>(e) ) {