Ticket #13964: 13964_boolean_degree.patch

File 13964_boolean_degree.patch, 2.2 KB (added by Charles Bouillaguet, 10 years ago)
  • sage/libs/polybori/decl.pxd

    # HG changeset patch
    # User Charles Bouillaguet <charles.bouillaguet@lifl.fr>
    # Date 1358527754 -3600
    # Node ID 68c09f7e0c1a94dc328a83d586ebd35720d2e176
    # Parent  9e1032a3f1cf8ccc40b6ad11930cddb8a1770c35
    trac 13964: BooleanPolynomial.degree() does not return the degree in a given variable
    
    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)()
    166168
    167169    PBSet pb_include_divisors "include_divisors" (PBSet p)
    168170    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  
    32873287        """
    32883288        return self._pbpoly.deg()
    32893289
    3290     def degree(self):
     3290    def degree(self, x=None):
    32913291        r"""
    3292         Return the total degree of ``self``.
    3293        
     3292        Return the maximal degree of this polynomial in ``x``, where
     3293        ``x`` must be one of the generators for the parent of this
     3294        polynomial.
     3295
     3296        If x is not specified (or is ``None``), return the total
     3297        degree, which is the maximum degree of any monomial.
     3298
    32943299        EXAMPLES::
    3295        
     3300
    32963301            sage: P.<x,y> = BooleanPolynomialRing(2)
    32973302            sage: (x+y).degree()
    32983303            1
    3299        
     3304
    33003305        ::
    3301        
     3306
    33023307            sage: P(1).degree()
    33033308            0
    3304        
     3309
    33053310        ::
    3306        
     3311
    33073312            sage: (x*y + x + y + 1).degree()
    33083313            2
    3309         """
     3314
     3315            sage: (x*y + x + y + 1).degree(x)
     3316            1
     3317        """
     3318        if x != None:
     3319            if self._pbpoly.set().multiplesOf((<BooleanPolynomial>x)._pbpoly.firstTerm()).isZero():
     3320                return 0
     3321            else:
     3322                return 1
    33103323        return self._pbpoly.deg()
    33113324
    33123325    def lm(BooleanPolynomial self):
     
    54225435            sage: BS.empty()
    54235436            True
    54245437        """
    5425         return self._pbset.size() == 0
     5438        return self._pbset.isZero()
    54265439
    54275440    def navigation(self):
    54285441        """