Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: singclap_pmod and singclap_pdivide with integer coefficients
PostPosted: Tue Jul 24, 2018 2:25 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject: Re: singclap_pmod and singclap_pdivide with integer coefficients
PostPosted: Wed Jul 25, 2018 12:26 pm 

Joined: Wed May 25, 2005 4:16 pm
Posts: 275
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 );
   }



Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: singclap_pmod and singclap_pdivide with integer coefficients
PostPosted: Sun Jul 29, 2018 6:38 pm 

Joined: Wed Jul 25, 2018 12:05 am
Posts: 8
We ended up using `p_Divide` and it seems to work. Thank you :)


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

It is currently Fri May 13, 2022 10:57 am
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group