Skip to content

Commit 57d6d61

Browse files
committed
some details in multi_polynomial base
1 parent b002b63 commit 57d6d61

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

src/sage/rings/polynomial/multi_polynomial_ring_base.pyx

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing):
4141
4242
sage: R.<x,y> = ZZ['x,y']; R
4343
Multivariate Polynomial Ring in x, y over Integer Ring
44-
sage: class CR(CommutativeRing):
44+
sage: cat = Rings().Commutative()
45+
sage: class CR(Parent):
4546
....: def __init__(self):
46-
....: CommutativeRing.__init__(self,self)
47-
....: def __call__(self,x):
47+
....: Parent.__init__(self, self, category=cat)
48+
....: def __call__(self, x):
4849
....: return None
4950
sage: cr = CR()
5051
sage: cr.is_commutative()
@@ -668,7 +669,7 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing):
668669

669670
def repr_long(self):
670671
"""
671-
Return structured string representation of self.
672+
Return structured string representation of ``self``.
672673
673674
EXAMPLES::
674675
@@ -758,7 +759,6 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing):
758759
Order: Graded Reverse Lexicographical
759760
Variables: T, W
760761
761-
762762
sage: # optional - magma
763763
sage: magma(PolynomialRing(GF(7),4, 'x'))
764764
Polynomial ring of rank 4 over GF(7)
@@ -868,12 +868,12 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing):
868868

869869
def gen(self, n=0):
870870
if n < 0 or n >= self._ngens:
871-
raise ValueError("Generator not defined.")
871+
raise ValueError("generator not defined")
872872
return self._gens[int(n)]
873873

874874
def variable_names_recursive(self, depth=sage.rings.infinity.infinity):
875875
r"""
876-
Returns the list of variable names of this and its base rings, as if
876+
Return the list of variable names of this and its base rings, as if
877877
it were a single multi-variate polynomial.
878878
879879
EXAMPLES::
@@ -883,7 +883,6 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing):
883883
('x', 'y', 'z', 'w')
884884
sage: R.variable_names_recursive(3)
885885
('y', 'z', 'w')
886-
887886
"""
888887
if depth <= 0:
889888
all = ()
@@ -901,7 +900,8 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing):
901900

902901
def _mpoly_base_ring(self, vars=None):
903902
"""
904-
Returns the base ring if this is viewed as a polynomial ring over vars.
903+
Return the base ring if this is viewed as a polynomial ring over vars.
904+
905905
See also MPolynomial._mpoly_dict_recursive.
906906
"""
907907
if vars is None:
@@ -1015,10 +1015,7 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing):
10151015
if not comb:
10161016
return (d,)
10171017
monomial = [comb[0]]
1018-
res = []
1019-
for j in range(n - 2):
1020-
res.append(comb[j + 1] - comb[j] - 1)
1021-
monomial += res
1018+
monomial.extend(comb[j + 1] - comb[j] - 1 for j in range(n - 2))
10221019
monomial.append(n + d - 1 - comb[-1] - 1)
10231020
return tuple(monomial)
10241021

@@ -1234,7 +1231,6 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing):
12341231
True
12351232
sage: R.random_element().parent() == R
12361233
True
1237-
12381234
"""
12391235
k = self.base_ring()
12401236
n = self.ngens()
@@ -1243,7 +1239,7 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing):
12431239

12441240
# Note that 'terms' could be None while 'total' is a
12451241
# nonnegative integer, so the comparison 'terms > total' could
1246-
# fail in Python 3.
1242+
# fail
12471243
if terms and terms > total:
12481244
terms = total
12491245

@@ -1526,13 +1522,14 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing):
15261522

15271523
def macaulay_resultant(self, *args, **kwds):
15281524
r"""
1529-
This is an implementation of the Macaulay resultant. It computes
1530-
the resultant of universal polynomials as well as polynomials
1531-
with constant coefficients. This is a project done in
1532-
sage days 55. It's based on the implementation in Maple by
1533-
Manfred Minimair, which in turn is based on the references listed below:
1534-
It calculates the Macaulay resultant for a list of polynomials,
1535-
up to sign!
1525+
Return the Macaulay resultant.
1526+
1527+
This computes the resultant of universal polynomials as well as
1528+
polynomials with constant coefficients. This is a project done
1529+
in sage days 55. It is based on the implementation in Maple by
1530+
Manfred Minimair, which in turn is based on the references
1531+
listed below. It calculates the Macaulay resultant for a list
1532+
of polynomials, up to sign!
15361533
15371534
REFERENCES:
15381535
@@ -1562,6 +1559,7 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing):
15621559
- the Macaulay resultant, an element of the base ring of ``self``
15631560
15641561
.. TODO::
1562+
15651563
Working with sparse matrices should usually give faster results,
15661564
but with the current implementation it actually works slower.
15671565
There should be a way to improve performance with regards to this.
@@ -1684,7 +1682,7 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing):
16841682
else:
16851683
flist = args
16861684

1687-
if len(flist) <= 0:
1685+
if len(flist) == 0:
16881686
raise TypeError('input list should contain at least 1 polynomial')
16891687
if not all(f.is_homogeneous() for f in flist):
16901688
raise TypeError('resultant for non-homogeneous polynomials is not supported')

0 commit comments

Comments
 (0)