# Ticket #5891: categories-numberfield_homset-nt.patch

File categories-numberfield_homset-nt.patch, 3.8 KB (added by nthiery, 12 years ago)
• ## sage/rings/number_field/number_field.py

```Bug fix: Hom(F, V) was returning a NumberFieldHomset even if V was not a number field; needs review!

This needs review and cleanup by specialists.

The current fix required to add a trivial is_field() method for gap
objects which always returns False. This is dubious.

diff --git a/sage/rings/number_field/number_field.py b/sage/rings/number_field/number_field.py```
 a from itertools import count, izip from sage.rings.integer_ring import IntegerRing # Like the usual is_NumberField, but accepts CC / RR / ... # Used by F._Hom_(K) on K to determine if the created homsets should # be a NumberFieldHomset # Experts: please redefine this properly and/or put CC/RR/... in NumberFields() def is_NumberFieldHomsetCodomain(codomain): from sage.rings.field import is_Field try: # is_Field does not work on gap objects, InfinityRing, ... We assume they are not number fields. if is_Field(codomain): return True except: pass return False def proof_flag(t): """ Used for easily determining the correct proof flag to use. class NumberField_generic(number_field_b Automorphism group of Number Field in i with defining polynomial x^2 + 1 sage: Hom(K, QuadraticField(-1, 'b')) Set of field embeddings from Number Field in i with defining polynomial x^2 + 1 to Number Field in b with defining polynomial x^2 + 1 """ import morphism return morphism.NumberFieldHomset(self, codomain) CHECKME: handling of the case where codomain is not a number field? sage: Hom(K, VectorSpace(QQ,3)) Set of Morphisms from Number Field in i with defining polynomial x^2 + 1 to Vector space of dimension 3 over Rational Field in Category of abelian groups """ if is_NumberFieldHomsetCodomain(codomain): import morphism return morphism.NumberFieldHomset(self, codomain) else: return NotImplemented def _set_structure(self, from_self, to_self, unsafe_force_change=False): """ class NumberField_cyclotomic(NumberField sage: End(CyclotomicField(21)) Automorphism group of Cyclotomic Field of order 21 and degree 12 """ import morphism return morphism.CyclotomicFieldHomset(self, codomain) if is_NumberFieldHomsetCodomain(codomain): import morphism return morphism.CyclotomicFieldHomset(self, codomain) else: return NotImplemented def is_galois(self): """ class NumberField_cyclotomic(NumberField """ if not isinstance(other, NumberField_generic): raise ValueError, "other must be a generic number field." return self._Hom_(other).order() > 0 return self.Hom(other).order() > 0 def complex_embedding(self, prec=53): r"""
• ## sage/rings/number_field/number_field_rel.py

`diff --git a/sage/rings/number_field/number_field_rel.py b/sage/rings/number_field/number_field_rel.py`
 a class NumberField_relative(NumberField_g sage: type(K.Hom(K)) """ import morphism return morphism.RelativeNumberFieldHomset(self, codomain) from number_field import is_NumberFieldHomsetCodomain if is_NumberFieldHomsetCodomain(codomain): import morphism return morphism.RelativeNumberFieldHomset(self, codomain) else: return NotImplemented def _latex_(self): r"""