Ticket #3432: trac_3432_degrees.patch
| File trac_3432_degrees.patch, 2.5 kB (added by malb, 5 months ago) |
|---|
-
a/sage/rings/polynomial/multi_polynomial_element.py
old new 383 383 return gcd(self.coefficients(),integer=self.parent() is ZZ) 384 384 385 385 def degrees(self): 386 """387 Returns a list (precisely -- an \code{ETuple}) with the degree of388 each variable in this polynomial. The list of degrees is, of course,389 ordered by the order of the generators.386 r""" 387 Returns a tuple (precisely -- an \code{ETuple}) with the 388 degree of each variable in this polynomial. The list of 389 degrees is, of course, ordered by the order of the generators. 390 390 391 391 EXAMPLES: 392 392 sage: R.<x,y,z>=PolynomialRing(ZZ) -
a/sage/rings/polynomial/multi_polynomial_libsingular.pyx
old new 2181 2181 if(r != currRing): rChangeCurrRing(r) 2182 2182 return pLDeg(p,&l,r) 2183 2183 2184 def degrees(self): 2185 r""" 2186 Returns a tuple with the maximl degree of each variable in 2187 this polynomial. The list of degrees is ordered by the order 2188 of the generators. 2189 2190 EXAMPLE: 2191 sage: R.<y0,y1,y2> = PolynomialRing(QQ,3) 2192 sage: q = 3*y0*y1*y1*y2; q 2193 3*y0*y1^2*y2 2194 sage: q.degrees() 2195 (1, 2, 1) 2196 sage: (q + y0^5).degrees() 2197 (5, 2, 1) 2198 """ 2199 cdef poly *p = self._poly 2200 cdef ring *r = (<MPolynomialRing_libsingular>self._parent)._ring 2201 cdef int i 2202 cdef list d = [0 for _ in range(r.N)] 2203 while p: 2204 for i from 0 <= i < r.N: 2205 d[i] = max(d[i],p_GetExp(p, i+1, r)) 2206 p = pNext(p) 2207 return tuple(d) 2208 2184 2209 def coefficient(self, degrees): 2185 2210 """ 2186 2211 Return the coefficient of the variables with the degrees