Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 21 additions & 23 deletions src/sage/rings/polynomial/multi_polynomial_ring_base.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing):

sage: R.<x,y> = ZZ['x,y']; R
Multivariate Polynomial Ring in x, y over Integer Ring
sage: class CR(CommutativeRing):
sage: cat = Rings().Commutative()
sage: class CR(Parent):
....: def __init__(self):
....: CommutativeRing.__init__(self,self)
....: def __call__(self,x):
....: Parent.__init__(self, self, category=cat)
....: def __call__(self, x):
....: return None
sage: cr = CR()
sage: cr.is_commutative()
Expand Down Expand Up @@ -668,7 +669,7 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing):

def repr_long(self):
"""
Return structured string representation of self.
Return structured string representation of ``self``.

EXAMPLES::

Expand Down Expand Up @@ -758,7 +759,6 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing):
Order: Graded Reverse Lexicographical
Variables: T, W


sage: # optional - magma
sage: magma(PolynomialRing(GF(7),4, 'x'))
Polynomial ring of rank 4 over GF(7)
Expand Down Expand Up @@ -868,12 +868,12 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing):

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

def variable_names_recursive(self, depth=sage.rings.infinity.infinity):
r"""
Returns the list of variable names of this and its base rings, as if
Return the list of variable names of this and its base rings, as if
it were a single multi-variate polynomial.

EXAMPLES::
Expand All @@ -883,7 +883,6 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing):
('x', 'y', 'z', 'w')
sage: R.variable_names_recursive(3)
('y', 'z', 'w')

"""
if depth <= 0:
all = ()
Expand All @@ -901,7 +900,8 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing):

def _mpoly_base_ring(self, vars=None):
"""
Returns the base ring if this is viewed as a polynomial ring over vars.
Return the base ring if this is viewed as a polynomial ring over vars.

See also MPolynomial._mpoly_dict_recursive.
"""
if vars is None:
Expand Down Expand Up @@ -1015,10 +1015,7 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing):
if not comb:
return (d,)
monomial = [comb[0]]
res = []
for j in range(n - 2):
res.append(comb[j + 1] - comb[j] - 1)
monomial += res
monomial.extend(comb[j + 1] - comb[j] - 1 for j in range(n - 2))
monomial.append(n + d - 1 - comb[-1] - 1)
return tuple(monomial)

Expand Down Expand Up @@ -1234,7 +1231,6 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing):
True
sage: R.random_element().parent() == R
True

"""
k = self.base_ring()
n = self.ngens()
Expand All @@ -1243,7 +1239,7 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing):

# Note that 'terms' could be None while 'total' is a
# nonnegative integer, so the comparison 'terms > total' could
# fail in Python 3.
# fail
if terms and terms > total:
terms = total

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

def macaulay_resultant(self, *args, **kwds):
r"""
This is an implementation of the Macaulay resultant. It computes
the resultant of universal polynomials as well as polynomials
with constant coefficients. This is a project done in
sage days 55. It's based on the implementation in Maple by
Manfred Minimair, which in turn is based on the references listed below:
It calculates the Macaulay resultant for a list of polynomials,
up to sign!
Return the Macaulay resultant.

This computes the resultant of universal polynomials as well as
polynomials with constant coefficients. This is a project done
in sage days 55. It is based on the implementation in Maple by
Manfred Minimair, which in turn is based on the references
listed below. It calculates the Macaulay resultant for a list
of polynomials, up to sign!

REFERENCES:

Expand Down Expand Up @@ -1562,6 +1559,7 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing):
- the Macaulay resultant, an element of the base ring of ``self``

.. TODO::

Working with sparse matrices should usually give faster results,
but with the current implementation it actually works slower.
There should be a way to improve performance with regards to this.
Expand Down Expand Up @@ -1684,7 +1682,7 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing):
else:
flist = args

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