The division in factory is a division for polynomials over the rationals
(and over Z/p). It is fine to use it for polynomials over Z as long as the results are
the same, but it fails for example for (3x+3)/(2x+2): factory returns in this case 3/2
which gets converted to 3, which is obviously wrong.
One possible solution would be to use p_Divide,
which uses singclap_pdivide (polynomials over Z/p, Q) resp. idLift (otherwise).
p_Divide(p,q) for polynomials over Z will return p/q if p is divisible by q, 0 otherwise.
Another possibility would be to use factory (via a modified singclap_pdivide)
and check the result for rational coefficients.
If one is sure p is divisible by q (like computation of gcd,lcm),
the simplest solution would be,
to change singclap_pdivide and use it ONLY in this case:
Code:
@@ -564,14 +564,14 @@ poly singclap_pdivide ( poly f, poly g, const ring r )
{
poly res=NULL;
On(SW_RATIONAL);
- if (rField_is_Zp(r) || rField_is_Q(r)
+ if (rField_is_Zp(r) || rField_is_Q(r) || rField_is_Z(r)
|| (rField_is_Zn(r)&&(r->cf->convSingNFactoryN!=ndConvSingNFactoryN)))
{
+ if (rField_is_Z(r)) Off(SW_RATIONAL);
setCharacteristic( rChar(r) );
CanonicalForm F( convSingPFactoryP( f,r ) ), G( convSingPFactoryP( g,r ) );
res = convFactoryPSingP( F / G,r );
}