本文整理汇总了Python中sage.structure.richcmp.richcmp函数的典型用法代码示例。如果您正苦于以下问题:Python richcmp函数的具体用法?Python richcmp怎么用?Python richcmp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了richcmp函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _richcmp_
def _richcmp_(self, other, op):
r"""
Compare self and other (where the coercion model has already ensured
that self and other have the same parent). Hecke operators on the same
space compare as equal if and only if their matrices are equal, so we
check if the indices are the same and if not we compute the matrices
(which is potentially expensive).
EXAMPLES::
sage: M = ModularSymbols(Gamma0(7), 4)
sage: m = M.hecke_operator(3)
sage: m == m
True
sage: m == 2*m
False
sage: m == M.hecke_operator(5)
False
These last two tests involve a coercion::
sage: m == m.matrix_form()
True
sage: m == m.matrix()
False
"""
if not isinstance(other, HeckeOperator):
if isinstance(other, HeckeAlgebraElement_matrix):
return richcmp(self.matrix_form(), other, op)
else:
raise RuntimeError("Bug in coercion code") # can't get here
if self.__n == other.__n:
return rich_to_bool(op, 0)
return richcmp(self.matrix(), other.matrix(), op)
开发者ID:saraedum,项目名称:sage-renamed,代码行数:35,代码来源:hecke_operator.py
示例2: __richcmp__
def __richcmp__(self, other, op):
r"""
Standard comparison function for Kodaira Symbols.
EXAMPLES::
sage: from sage.schemes.elliptic_curves.kodaira_symbol import KodairaSymbol_class
sage: KS1 = KodairaSymbol_class(15); KS1
I11
sage: KS2 = KodairaSymbol_class(-34); KS2
I30*
sage: KS1 < KS2
True
sage: KS2 < KS1
False
::
sage: Klist = [KodairaSymbol_class(i) for i in [-10..10] if i!=0]
sage: Klist.sort()
sage: Klist
[I0,
I0*,
I1,
I1*,
I2,
I2*,
I3,
I3*,
I4,
I4*,
I5,
I5*,
I6,
I6*,
II,
II*,
III,
III*,
IV,
IV*]
"""
if isinstance(other, KodairaSymbol_class):
if (self._n == "generic" and not other._n is None) or (other._n == "generic" and not self._n is None):
return richcmp(self._starred, other._starred, op)
return richcmp(self._str, other._str, op)
else:
return NotImplemented
开发者ID:saraedum,项目名称:sage-renamed,代码行数:48,代码来源:kodaira_symbol.py
示例3: _richcmp_
def _richcmp_(self, other, op):
"""
Rich comparison of ``self`` to ``other``.
EXAMPLES::
sage: F.<x,y> = FreeAlgebra(ZZ)
sage: H = F.hochschild_complex(F)
sage: a = H({0: x - y,
....: 1: H.module(1).basis().an_element(),
....: 2: H.module(2).basis().an_element()})
sage: a == 3*a
False
sage: a + a == 2*a
True
sage: a == H.zero()
False
sage: a != 3*a
True
sage: a + a != 2*a
False
sage: a != H.zero()
True
"""
return richcmp(self._vec, other._vec, op)
开发者ID:mcognetta,项目名称:sage,代码行数:26,代码来源:hochschild_complex.py
示例4: __richcmp__
def __richcmp__(self, other, op):
r"""
Rich comparison for class functions.
Compares groups and then the values of the class function on the
conjugacy classes.
EXAMPLES::
sage: G = PermutationGroup([[(1,2,3),(4,5)],[(3,4)]])
sage: chi = G.character([1, 1, 1, 1, 1, 1, 1])
sage: H = PermutationGroup([[(1,2,3),(4,5)]])
sage: xi = H.character([1, 1, 1, 1, 1, 1])
sage: chi == chi
True
sage: xi == xi
True
sage: xi == chi
False
sage: chi < xi
False
sage: xi < chi
True
"""
if isinstance(other, ClassFunction_libgap):
return richcmp((self._group, self.values()),
(other._group, other.values()), op)
else:
return NotImplemented
开发者ID:saraedum,项目名称:sage-renamed,代码行数:29,代码来源:class_function.py
示例5: _richcmp_
def _richcmp_(self, other, op):
"""
Compare two linear expressions.
INPUT:
- ``other`` -- another linear expression (will be enforced by
the coercion framework)
EXAMPLES::
sage: from sage.geometry.linear_expression import LinearExpressionModule
sage: L.<x> = LinearExpressionModule(QQ)
sage: x == L([0, 1])
True
sage: x == x + 1
False
sage: M.<x> = LinearExpressionModule(ZZ)
sage: L.gen(0) == M.gen(0) # because there is a conversion
True
sage: L.gen(0) == L(M.gen(0)) # this is the conversion
True
sage: x == 'test'
False
"""
return richcmp((self._coeffs, self._const),
(other._coeffs, other._const), op)
开发者ID:sagemath,项目名称:sage,代码行数:29,代码来源:linear_expression.py
示例6: __richcmp__
def __richcmp__(self, other, op):
"""
Intervals are sorted by lower bound, then upper bound
OUTPUT:
`-1`, `0`, or `+1` depending on how the intervals compare.
EXAMPLES::
sage: I1 = RealSet.open_closed(1, 3); I1
(1, 3]
sage: I2 = RealSet.open_closed(0, 5); I2
(0, 5]
sage: cmp(I1, I2)
1
sage: sorted([I1, I2])
[(0, 5], (1, 3]]
sage: I1 == I1
True
"""
if not isinstance(other, RealSet):
return NotImplemented
# note that the interval representation is normalized into a
# unique form
return richcmp(self._intervals, other._intervals, op)
开发者ID:mcognetta,项目名称:sage,代码行数:26,代码来源:real_set.py
示例7: _richcmp_
def _richcmp_(self, other, op):
"""
Compare two free monoid elements with the same parents.
The ordering is first by increasing length, then lexicographically
on the underlying word.
EXAMPLES::
sage: S = FreeMonoid(3, 'a')
sage: (x,y,z) = S.gens()
sage: x * y < y * x
True
sage: a = FreeMonoid(5, 'a').gens()
sage: x = a[0]*a[1]*a[4]**3
sage: x < x
False
sage: x == x
True
sage: x >= x*x
False
"""
m = sum(i for x, i in self._element_list)
n = sum(i for x, i in other._element_list)
if m != n:
return richcmp_not_equal(m, n, op)
v = tuple([x for x, i in self._element_list for j in range(i)])
w = tuple([x for x, i in other._element_list for j in range(i)])
return richcmp(v, w, op)
开发者ID:saraedum,项目名称:sage-renamed,代码行数:30,代码来源:free_monoid_element.py
示例8: _richcmp_
def _richcmp_(left, right, op):
"""
Compare ``left`` and ``right``.
INPUT:
- ``right`` -- a :class:`FormalSum` with the same parent
- ``op`` -- a comparison operator
EXAMPLES::
sage: a = FormalSum([(1,3),(2,5)]); a
3 + 2*5
sage: b = FormalSum([(1,3),(2,7)]); b
3 + 2*7
sage: a != b
True
sage: a_QQ = FormalSum([(1,3),(2,5)],parent=FormalSums(QQ))
sage: a == a_QQ # a is coerced into FormalSums(QQ)
True
sage: a == 0 # 0 is coerced into a.parent()(0)
False
"""
return richcmp(left._data, right._data, op)
开发者ID:saraedum,项目名称:sage-renamed,代码行数:25,代码来源:formal_sum.py
示例9: __richcmp__
def __richcmp__(self, other, op):
"""
Compare ``self`` and ``other``.
INPUT:
- ``other`` -- anything.
OUTPUT:
Two faces test equal if and only if they are faces of the same
(not just isomorphic) polyhedron and their generators have the
same indices.
EXAMPLES::
sage: square = polytopes.hypercube(2)
sage: f = square.faces(1)
sage: matrix(4,4, lambda i,j: ZZ(f[i] <= f[j]))
[1 1 1 1]
[0 1 1 1]
[0 0 1 1]
[0 0 0 1]
sage: matrix(4,4, lambda i,j: ZZ(f[i] == f[j])) == 1
True
"""
if not isinstance(other, PolyhedronFace):
return NotImplemented
if self._polyhedron is not other._polyhedron:
return NotImplemented
return richcmp(self._ambient_Vrepresentation_indices,
other._ambient_Vrepresentation_indices, op)
开发者ID:saraedum,项目名称:sage-renamed,代码行数:32,代码来源:face.py
示例10: __richcmp__
def __richcmp__(self, other, op):
"""
Compare ``self`` to ``other``.
EXAMPLES::
sage: M = ModularSymbols(11)
sage: s = M.2.modular_symbol_rep()[0][1]
sage: t = M.0.modular_symbol_rep()[0][1]
sage: s, t
({-1/9, 0}, {Infinity, 0})
sage: s < t
True
sage: t > s
True
sage: s == s
True
sage: t == t
True
"""
if not isinstance(other, ModularSymbol):
return NotImplemented
return richcmp((self.__space, -self.__i, self.__alpha, self.__beta),
(other.__space,-other.__i,other.__alpha,other.__beta),
op)
开发者ID:saraedum,项目名称:sage-renamed,代码行数:25,代码来源:modular_symbols.py
示例11: __richcmp__
def __richcmp__(self, other, op):
r"""
Only quotients by the *same* ring and same ideal (with the same
generators!!) are considered equal.
EXAMPLES::
sage: R.<x,y> = PolynomialRing(QQ)
sage: S = R.quotient_ring(x^2 + y^2)
sage: S == R.quotient_ring(x^2 + y^2)
True
The ideals `(x^2 + y^2)` and `(-x^2-y^2)` are
equal, but since the generators are different, the corresponding
quotient rings are not equal::
sage: R.ideal(x^2+y^2) == R.ideal(-x^2 - y^2)
True
sage: R.quotient_ring(x^2 + y^2) == R.quotient_ring(-x^2 - y^2)
False
"""
if not isinstance(other, QuotientRing_nc):
return NotImplemented
return richcmp((self.cover_ring(), self.defining_ideal().gens()),
(other.cover_ring(), other.defining_ideal().gens()), op)
开发者ID:saraedum,项目名称:sage-renamed,代码行数:25,代码来源:quotient_ring.py
示例12: __richcmp__
def __richcmp__(self, right, op):
r"""
Compare ``self`` and ``right``.
If ``right`` is not a :class:`Set_object`, return ``NotImplemented``.
If ``right`` is also a :class:`Set_object`, returns comparison
on the underlying objects.
.. NOTE::
If `X < Y` is true this does *not* necessarily mean
that `X` is a subset of `Y`. Also, any two sets can be
compared still, but the result need not be meaningful
if they are not equal.
EXAMPLES::
sage: Set(ZZ) == Set(QQ)
False
sage: Set(ZZ) < Set(QQ)
True
sage: Primes() == Set(QQ)
False
The following is random, illustrating that comparison of
sets is not the subset relation, when they are not equal::
sage: Primes() < Set(QQ) # random
True or False
"""
if not isinstance(right, Set_object):
return NotImplemented
return richcmp(self.__object, right.__object, op)
开发者ID:saraedum,项目名称:sage-renamed,代码行数:33,代码来源:set.py
示例13: __richcmp__
def __richcmp__(self, J, op):
"""
Compare the Jacobian self to `J`. If `J` is a Jacobian, then
self and `J` are equal if and only if their curves are equal.
EXAMPLES::
sage: from sage.schemes.jacobians.abstract_jacobian import Jacobian
sage: P2.<x, y, z> = ProjectiveSpace(QQ, 2)
sage: J1 = Jacobian(Curve(x^3 + y^3 + z^3))
sage: J1 == J1
True
sage: J1 == P2
False
sage: J1 != P2
True
sage: J2 = Jacobian(Curve(x + y + z))
sage: J1 == J2
False
sage: J1 != J2
True
"""
if not is_Jacobian(J):
return NotImplemented
return richcmp(self.curve(), J.curve(), op)
开发者ID:saraedum,项目名称:sage-renamed,代码行数:25,代码来源:abstract_jacobian.py
示例14: _richcmp_
def _richcmp_(self, other, op):
"""
Rich comparison.
EXAMPLES::
sage: F = FreeAbelianMonoid(5, 'abcde')
sage: F(1)
1
sage: a, b, c, d, e = F.gens()
sage: x = a^2 * b^3
sage: F(1) < x
True
sage: x > b
True
sage: x <= a^4
True
sage: x != a*b
True
sage: a*b == b*a
True
sage: x > a^3*b^2
False
"""
return richcmp(self._element_vector, other._element_vector, op)
开发者ID:mcognetta,项目名称:sage,代码行数:25,代码来源:free_abelian_monoid_element.py
示例15: _richcmp_
def _richcmp_(self, other, op):
"""
EXAMPLES::
sage: C = crystals.FastRankTwo(['A',2],shape=[2,1])
sage: D = crystals.FastRankTwo(['B',2],shape=[2,1])
sage: C(0) == C(0)
True
sage: C(1) == C(0)
False
sage: C(0) == D(0)
False
sage: C = crystals.FastRankTwo(['A',2],shape=[2,1])
sage: D = crystals.FastRankTwo(['B',2],shape=[2,1])
sage: C(0) != C(0)
False
sage: C(1) != C(0)
True
sage: C(0) != D(0)
True
sage: C = crystals.FastRankTwo(['A',2],shape=[2,1])
sage: C(1) < C(2)
True
sage: C(2) < C(1)
False
sage: C(2) > C(1)
True
sage: C(1) <= C(1)
True
"""
return richcmp(self.value, other.value, op)
开发者ID:sagemath,项目名称:sage,代码行数:33,代码来源:fast_crystals.py
示例16: _richcmp_
def _richcmp_(self, other, op):
"""
Rich comparison for equal parents.
TESTS::
sage: R.<x,y,z> = QQ[]
sage: W = DifferentialWeylAlgebra(R)
sage: dx,dy,dz = W.differentials()
sage: dy*(x^3-y*z)*dx == -z*dx + x^3*dx*dy - y*z*dx*dy
True
sage: W.zero() == 0
True
sage: W.one() == 1
True
sage: x == 1
False
sage: x + 1 == 1
False
sage: W(x^3 - y*z) == x^3 - y*z
True
sage: W.<x,y,z> = DifferentialWeylAlgebra(QQ)
sage: dx,dy,dz = W.differentials()
sage: dx != dy
True
sage: W.one() != 1
False
"""
return richcmp(self.__monomials, other.__monomials, op)
开发者ID:saraedum,项目名称:sage-renamed,代码行数:29,代码来源:weyl_algebra.py
示例17: __richcmp__
def __richcmp__(self, other, op):
"""
Compare torsion subgroups.
INPUT:
- ``other`` -- an object
If other is a torsion subgroup, the abelian varieties are compared.
Otherwise, the generic behavior for finite abelian variety
subgroups is used.
EXAMPLES::
sage: G = J0(11).rational_torsion_subgroup(); H = J0(13).rational_torsion_subgroup()
sage: G == G
True
sage: G < H # since 11 < 13
True
sage: G > H
False
"""
if isinstance(other, RationalTorsionSubgroup):
return richcmp(self.abelian_variety(), other.abelian_variety(), op)
return FiniteSubgroup.__richcmp__(self, other, op)
开发者ID:saraedum,项目名称:sage-renamed,代码行数:25,代码来源:torsion_subgroup.py
示例18: __richcmp__
def __richcmp__(self, other, op):
"""
Rich comparison.
EXAMPLES::
sage: ct1 = CartanType(['A',1],['B',2])
sage: ct2 = CartanType(['B',2],['A',1])
sage: ct3 = CartanType(['A',4])
sage: ct1 == ct1
True
sage: ct1 == ct2
False
sage: ct1 == ct3
False
TESTS:
Check that :trac:`20418` is fixed::
sage: ct = CartanType(["A2", "B2"])
sage: ct == (1, 2, 1)
False
"""
if isinstance(other, CartanType_simple):
return rich_to_bool(op, 1)
if not isinstance(other, CartanType):
return NotImplemented
return richcmp(self._types, other._types, op)
开发者ID:saraedum,项目名称:sage-renamed,代码行数:29,代码来源:type_reducible.py
示例19: _richcmp_
def _richcmp_(self, other, op):
"""
Rich comparison of morphisms.
EXAMPLES::
sage: V = ZZ^2
sage: phi = V.hom([3*V.0, 2*V.1])
sage: psi = V.hom([5*V.0, 5*V.1])
sage: id = V.hom([V.0, V.1])
sage: phi == phi
True
sage: phi == psi
False
sage: psi == End(V)(5)
True
sage: psi == 5 * id
True
sage: psi == 5 # no coercion
False
sage: id == End(V).identity()
True
"""
if not isinstance(other, MatrixMorphism) or op not in (op_EQ, op_NE):
# Generic comparison
return sage.categories.morphism.Morphism._richcmp_(self, other, op)
return richcmp(self.matrix(), other.matrix(), op)
开发者ID:saraedum,项目名称:sage-renamed,代码行数:27,代码来源:matrix_morphism.py
示例20: __richcmp__
def __richcmp__(self, other, op):
"""
Standard comparison function.
The ordering is just lexicographic on the tuple `(u,r,s,t)`.
.. NOTE::
In a list of automorphisms, there is no guarantee that the
identity will be first!
EXAMPLES::
sage: from sage.schemes.elliptic_curves.weierstrass_morphism import baseWI
sage: baseWI(1,2,3,4) == baseWI(1,2,3,4)
True
sage: baseWI(1,2,3,4) < baseWI(1,2,3,5)
True
sage: baseWI(1,2,3,4) > baseWI(1,2,3,4)
False
It will never return equality if other is of another type::
sage: baseWI() == 1
False
"""
if not isinstance(other, baseWI):
return (op == op_NE)
return richcmp(self.tuple(), other.tuple(), op)
开发者ID:mcognetta,项目名称:sage,代码行数:29,代码来源:weierstrass_morphism.py
注:本文中的sage.structure.richcmp.richcmp函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论