Ticket #13728: trac_13728-some_standard_methods_for_fields-cs.patch

File trac_13728-some_standard_methods_for_fields-cs.patch, 2.9 KB (added by stumpc5, 7 years ago)
• sage/categories/fields.py

```# HG changeset patch
# User Christian Stump <christian.stump at gmail.com>
# Date 1353406852 -3600
# Node ID 492f622bb6de5436e02144cf4696ae98f8e6c0f4
# Parent  e9f529e33ab1e30f376c5c8e452c03d2ce0d11f4
implements some basic methods for fields

diff --git a/sage/categories/fields.py b/sage/categories/fields.py```
 a class Fields(Category_singleton): except NotImplementedError: return def is_integral_domain(self): r""" Returns ``True``, as fields are integral domains. EXAMPLES:: sage: QQ.is_integral_domain() True """ return True def is_field( self, proof=True ): r""" Returns True as ``self`` is a field. EXAMPLES:: sage: QQ.is_field() True """ return True def fraction_field(self): r""" Returns the *fraction field* of ``self``, which is ``self``. EXAMPLES:: sage: QQ.fraction_field() is QQ True """ return self def __pow__(self, n): r""" Returns the vector space of dimension `n` over ``self``. EXAMPLES:: sage: QQ^4 Vector space of dimension 4 over Rational Field """ from sage.modules.all import FreeModule return FreeModule(self, n) class ElementMethods: def is_unit( self ): r""" Returns True if ``self`` has a multiplicative inverse. EXAMPLES:: sage: QQ(2).is_unit() True sage: QQ(0).is_unit() False """ return not self.is_zero() # Fields are unique factorization domains, so, there is gcd and lcm # Of course, in general gcd and lcm in a field are not very interesting. # However, they should be implemented!
• sage/rings/polynomial/polynomial_quotient_ring.py

`diff --git a/sage/rings/polynomial/polynomial_quotient_ring.py b/sage/rings/polynomial/polynomial_quotient_ring.py`
 a class PolynomialQuotientRing_generic(sag sage: first_class == Q.__class__ False sage: [s for s in dir(Q.category().element_class) if not s.startswith('_')] ['cartesian_product', 'gcd', 'is_idempotent', 'is_one', 'lcm', 'lift'] ['cartesian_product', 'gcd', 'is_idempotent', 'is_one', 'is_unit', 'lcm', 'lift'] As one can see, the elements are now inheriting additional methods: lcm and gcd. Even though ``Q.an_element()`` belongs to the old and not to the new element class, it still inherits