*/
/*
- * GiNaC Copyright (C) 1999-2009 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2015 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
}
bool is_col_zero(size_t col) const
{
- mvec::const_iterator i = m.begin() + col;
for ( size_t rr=0; rr<r; ++rr ) {
std::size_t i = col + rr*c;
if ( !zerop(m[i]) ) {
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) ) {