summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Krenn <devel@danielkrenn.at>2014-12-27 08:27:34 +0100
committerDaniel Krenn <devel@danielkrenn.at>2014-12-27 08:27:34 +0100
commit94d860d00013d6176b5bfa6bf72b468987310466 (patch)
treebac3f6689259efeb9813597043941b22106e46e1
parentimplement _coerce_map_form_ (diff)
implement equality testing (using coercion model)
-rw-r--r--src/sage/combinat/asymptotics_multivariate_generating_functions.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/sage/combinat/asymptotics_multivariate_generating_functions.py b/src/sage/combinat/asymptotics_multivariate_generating_functions.py
index 392bfb0..716b17f 100644
--- a/src/sage/combinat/asymptotics_multivariate_generating_functions.py
+++ b/src/sage/combinat/asymptotics_multivariate_generating_functions.py
@@ -513,6 +513,7 @@ class FFPDElement(sage.structure.element.RingElement):
"""
return self.numerator()/self.denominator()
+
def __repr__(self):
r"""
Return a string representation of ``self``
@@ -528,8 +529,56 @@ class FFPDElement(sage.structure.element.RingElement):
"""
return repr((self.numerator(), self.denominator_factored()))
+
def __eq__(self, other):
r"""
+ Tests for equality of the given elements (with taking care of
+ different parents by using the coercion model).
+
+ INPUT:
+
+ - ``other`` -- object to compare with ``self``.
+
+ OUTPUT:
+
+ ``True`` or ``False``.
+
+ TESTS::
+
+ sage: from sage.combinat.asymptotics_multivariate_generating_functions import FractionWithFactoredDenominatorRing
+ sage: R.<x,y> = PolynomialRing(QQ)
+ sage: FFPD = FractionWithFactoredDenominatorRing(R)
+ sage: f = FFPD(x, [])
+ sage: f == x
+ True
+ sage: x == f
+ True
+ sage: f == 4
+ False
+ sage: g = FFPD(R(3), [])
+ sage: g == R(3)
+ True
+ sage: g == QQ(3)
+ True
+ sage: g == ZZ(3)
+ True
+ sage: 3 == g
+ True
+ """
+ from sage.structure.sage_object import have_same_parent
+ if have_same_parent(self, other):
+ return self._eq_(other)
+
+ from sage.structure.element import get_coercion_model
+ import operator
+ try:
+ return get_coercion_model().bin_op(self, other, operator.eq)
+ except TypeError:
+ return False
+
+
+ def _eq_(self, other):
+ r"""
Two FFPD instances are equal iff they represent the same
fraction.
@@ -560,6 +609,7 @@ class FFPDElement(sage.structure.element.RingElement):
"""
return self.quotient() == other.quotient()
+
def __ne__(self, other):
r"""
EXAMPLES::
@@ -578,6 +628,7 @@ class FFPDElement(sage.structure.element.RingElement):
"""
return not (self == other)
+
def __lt__(self, other):
r"""
FFPD ``A`` is less than FFPD ``B`` iff
@@ -621,6 +672,7 @@ class FFPDElement(sage.structure.element.RingElement):
(len(sdf) == len(odf) and sd < od) or\
(len(sdf) == len(odf) and sd == od and sn < on))
+
def univariate_decomposition(self):
r"""
Return the usual univariate partial fraction decomposition