Opened 7 years ago

Closed 7 years ago

#13964 closed defect (fixed)

Missing conversion from PolynomialBooleanRing to (univariate) PolynomialRing over GF(2) via NTL

Reported by: Bouillaguet Owned by: malb
Priority: major Milestone: sage-5.7
Component: commutative algebra Keywords:
Cc: malb, AlexanderDreyer, PolyBoRi Merged in: sage-5.7.beta0
Authors: Charles Bouillaguet Reviewers: Alexander Dreyer
Report Upstream: None of the above - read trac for reasoning. Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description

sage: R_multi.<x,y,z> = BooleanPolynomialRing() 
sage: R_uni = GF(2)[x]
sage: R_uni( x )
Traceback (most recent call last):
....
TypeError: degree() takes no arguments (1 given)

Attachments (1)

13964_boolean_degree.patch (2.2 KB) - added by Bouillaguet 7 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 7 years ago by Bouillaguet

  • Authors set to Charles Bouillaguet
  • Status changed from new to needs_review

Turns out that the problem is that in BooleanPolynomialRing, the degree() method did not have the same specification as that in "normal" MPolynomial rings...

comment:2 Changed 7 years ago by AlexanderDreyer

The patch does what expected, but I would use a different test for performance reasons, see here:

  • sage/libs/polybori/decl.pxd

    diff --git a/sage/libs/polybori/decl.pxd b/sage/libs/polybori/decl.pxd    
    a b  
    163163        double (* sizeDouble)()                                         
    164164        PBSetIter (* begin)()                                           
    165165        PBSetIter (* end)()                                             
     166        bint (* isZero)()                                               
     167        bint (* isOne)()                                                 
     168                                                                         
    166169                                                                         
    167170    PBSet pb_include_divisors "include_divisors" (PBSet p)               
    168171    PBSet pb_minimal_elements "minimal_elements" (PBSet p)               
  • sage/rings/polynomial/pbori.pyx

    diff --git a/sage/rings/polynomial/pbori.pyx b/sage/rings/polynomial/pbori.pyx
    a b  
    32363236        """
    32373237        return self._pbpoly.deg()
    32383238
    3239     def degree(self):
     3239    def degree(self,x=None):
    32403240        r"""
    32413241        Return the total degree of ``self``.
    32423242
     
    32563256            sage: (x*y + x + y + 1).degree()
    32573257            2
    32583258        """
     3259        if x != None:
     3260          if self._pbpoly.set().multiplesOf((<BooleanPolynomial>x)._pbpoly.firstTerm()).isZero():
     3261              return 0
     3262          else:
     3263              return 1
     3264
    32593265        return self._pbpoly.deg()
    32603266
    32613267    def lm(BooleanPolynomial self):
     
    53575363            sage: BS.empty()
    53585364            True
    53595365        """
    5360         return self._pbset.size() == 0
     5366        return self._pbset.isZero()
    53615367
    53625368    def navigation(self):
    53635369        """

(The improved empty() should also be added.

Changed 7 years ago by Bouillaguet

comment:3 Changed 7 years ago by Bouillaguet

  • Keywords conversion removed

This new patch should make you happy :)

comment:4 Changed 7 years ago by AlexanderDreyer

  • Report Upstream changed from N/A to None of the above - read trac for reasoning.
  • Reviewers set to Alexander Dreyer
  • Status changed from needs_review to positive_review

Indeed, so positive review!

comment:5 Changed 7 years ago by jdemeyer

  • Merged in set to sage-5.7.beta0
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.