Singular
https://www.singular.uni-kl.de/forum/

singclap_pmod and singclap_pdivide with integer coefficients
https://www.singular.uni-kl.de/forum/viewtopic.php?f=10&t=2768
Page 1 of 1

Author:  timokau [ Tue Jul 24, 2018 2:25 pm ]
Post subject:  singclap_pmod and singclap_pdivide with integer coefficients

Hi!

The removal[1] of support for integer coefficients in `singclap_pmod` and `singclap_pdivide` with integer coefficients currently blocks[2] using the latest singular with sage.

We were using that in some places, for example computing `gcd` and `lcm` of two polynomials. We're thinking about different ways to work around this (see the comments in the ticket[2]. Could you expand on the reasoning of the removal? Do you maybe have suggestions on how to fix the problem with sage?


(apparently I'm "not allowed to post URLs")

[1] github DOT com/Singular/Sources/commit/4c1e770238d949fb0c7debc00998d507df876751
[2] trac.sagemath DOT org/ticket/24735#comment:4

Author:  hannes [ Wed Jul 25, 2018 12:26 pm ]
Post subject:  Re: singclap_pmod and singclap_pdivide with integer coefficients

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 );
   }


Author:  timokau [ Sun Jul 29, 2018 6:38 pm ]
Post subject:  Re: singclap_pmod and singclap_pdivide with integer coefficients

We ended up using `p_Divide` and it seems to work. Thank you :)

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/