# HG changeset patch
# User Francis Clarke <francis.w.clarke@gmail.com>
# Date 1298627770 0
# Node ID 05a4991534ec0c8ac25930628a45d836f63b7795
# Parent 2fcb23bf655ccafad123a763050806d8e1360cb7
#10850 composition and comparison of numberfield homomorphisms
diff r 2fcb23bf655c r 05a4991534ec sage/rings/morphism.pyx
a

b


657  657  """ 
658  658  If ``homset`` is a homset of rings and ``right`` is a 
659  659  ring homomorphism given by the images of generators, 
660   the composition with ``self`` will be of the same type. 
 660  (indirectly in the case of homomorphisms from relative 
 661  number fields), the composition with ``self`` will be 
 662  of the appropriate type. 
 663  
661  664  Otherwise, a formal composite map is returned. 
662  665  
663  666  EXAMPLES:: 
… 
… 

672  675  To: Fraction Field of Multivariate Polynomial Ring in a, b over Rational Field 
673  676  Defn: x > a + b 
674  677  y > a  b 
 678  
 679  When ``right`` is defined by the images of generators, the 
 680  result has the type of a homomorphism between its domain and 
 681  codomain:: 
 682  
 683  sage: C = CyclotomicField(24) 
 684  sage: f = End(C)[1] 
 685  sage: type(f*f) == type(f) 
 686  True 
 687  
 688  An example where the domain of ``right`` is a relative number field:: 
 689  sage: PQ.<X> = QQ[] 
 690  sage: K.<a, b> = NumberField([X^2  2, X^2  3]) 
 691  sage: e, u, v, w = End(K) 
 692  sage: u*v 
 693  Relative number field endomorphism of Number Field in a with defining polynomial X^2  2 over its base field 
 694  Defn: a > a 
 695  b > b 
 696  
 697  An example where ``right`` is not a ring homomorphism:: 
 698  
675  699  sage: from sage.categories.morphism import SetMorphism 
676  700  sage: h = SetMorphism(Hom(R,S,Rings()), lambda p: p[0]) 
677  701  sage: g*h 
… 
… 

686  710  From: Multivariate Polynomial Ring in a, b over Rational Field 
687  711  To: Fraction Field of Multivariate Polynomial Ring in a, b over Rational Field 
688  712  
689   AUTHOR: 
 713  AUTHORS: 
690  714  
691  715   Simon King (201005) 
 716   Francis Clarke (201102) 
692  717  
693  718  """ 
694  719  from sage.all import Rings 
695   if isinstance(right, RingHomomorphism_im_gens) and homset.homset_category().is_subcategory(Rings()): 
696   try: 
697   return RingHomomorphism_im_gens(homset, [self(g) for g in right.im_gens()]) 
698   except ValueError: 
699   pass 
 720  if homset.homset_category().is_subcategory(Rings()): 
 721  if isinstance(right, RingHomomorphism_im_gens): 
 722  try: 
 723  return homset([self(g) for g in right.im_gens()]) 
 724  except ValueError: 
 725  pass 
 726  from sage.rings.number_field.morphism import RelativeNumberFieldHomomorphism_from_abs 
 727  if isinstance(right, RelativeNumberFieldHomomorphism_from_abs): 
 728  try: 
 729  return homset(self*right.abs_hom()) 
 730  except ValueError: 
 731  pass 
700  732  return sage.categories.map.Map._composition_(self, right, homset) 
701  733  
702  734  def is_injective(self): 
diff r 2fcb23bf655c r 05a4991534ec sage/rings/number_field/morphism.py
a

b


616  616  self.__im_gens = v 
617  617  return v 
618  618  
 619  def __cmp__(self, other): 
 620  """ 
 621  Compare 
 622  EXAMPLES: 
 623  sage: K.<a, b> = NumberField([x^2  2, x^2  3]) 
 624  sage: e, u, v, w = End(K) 
 625  sage: all([u^2 == e, u*v == w, u != e]) 
 626  True 
 627  """ 
 628  if not isinstance(other, RelativeNumberFieldHomomorphism_from_abs): 
 629  return cmp(type(self), type(other)) 
 630  return cmp(self.abs_hom(), other.abs_hom()) 
 631  
619  632  def _repr_defn(self): 
620  633  r""" 
621  634  Return a string describing the images of the generators under this map. 