#4276: [with patch, needs review] move number fields to new coercion, implement
embeddings
----------------------+-----------------------------------------------------
 Reporter:  robertwb  |        Owner:  robertwb  
     Type:  defect    |       Status:  new       
 Priority:  major     |    Milestone:  sage-3.2.2
Component:  coercion  |   Resolution:            
 Keywords:            |  
----------------------+-----------------------------------------------------
Comment (by ncalexan):

 This code is good, it really is, but it's just not tested.  I don't have
 time right now to test it and I will be sans computer over the Christmas
 break.

 I have to give this a negative review because I do not believe the
 embeddings work in anything more than the trivial situation: two absolute
 fields, compatible embeddings into CC.

 On the other hand, I have no reservations about the coercion part of this
 patch.  Are we willing to accept almost certainly broken new functionality
 to have valuable infrastructure upgrades?

 {{{
 sage: L1 = NumberField(x^4 + 6*x^2 + 1, 'a', embedding=CC(5*I))
 sage: NumberField(x^4 + 6*x^2 + 1, 'a', embedding=L1.gen())
 ---------------------------------------------------------------------------
 TypeError                                 Traceback (most recent call
 last)

 
/Users/ncalexan/.sage/temp/pv139196.reshsg.uci.edu/23733/_Users_ncalexan__sage_init_sage_0.py
 in <module>()
 ----> 1
       2
       3
       4
       5

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/rings/number_field/number_field.pyc in
 NumberField(polynomial, name, check, names, cache, embedding)
     371         K = NumberField_quadratic(polynomial, name, check,
 embedding)
     372     else:
 --> 373         K = NumberField_absolute(polynomial, name, None, check,
 embedding)
     374
     375     if cache:

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/rings/number_field/number_field.pyc in __init__(self,
 polynomial, name, latex_name, check, embedding)
    3655         NumberField_generic.__init__(self, polynomial, name,
 latex_name, check, embedding)
    3656         self._element_class =
 number_field_element.NumberFieldElement_absolute
 -> 3657         self._zero_element = self(0)
    3658         self._one_element =  self(1)
    3659

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/structure/parent.so in sage.structure.parent.Parent.__call__
 (sage/structure/parent.c:3665)()
     277
     278
 --> 279
     280
     281

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/structure/parent.so in
 sage.structure.parent.Parent.convert_map_from
 (sage/structure/parent.c:8640)()
    1000
    1001
 -> 1002
    1003
    1004

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/structure/parent.so in
 sage.structure.parent.Parent.discover_convert_map_from
 (sage/structure/parent.c:8771)()
    1007
    1008
 -> 1009
    1010
    1011

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/structure/parent.so in
 sage.structure.parent.Parent.coerce_map_from
 (sage/structure/parent.c:7653)()
     876
     877
 --> 878
     879
     880

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/structure/parent.so in
 sage.structure.parent.Parent.discover_coerce_map_from
 (sage/structure/parent.c:7956)()
     921
     922
 --> 923
     924
     925

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/structure/parent_old.so in
 sage.structure.parent_old.Parent._coerce_map_from_
 (sage/structure/parent_old.c:6291)()
     576
     577
 --> 578
     579
     580

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/rings/number_field/number_field.pyc in
 _coerce_map_from_(self, R)
    1531         """
    1532         if R in [int, long, ZZ, QQ, self.base()]:
 -> 1533             return self._generic_convert_map(R)
    1534         from sage.rings.number_field.order import
 is_NumberFieldOrder
    1535         if is_NumberFieldOrder(R) and
 R.number_field().has_coerce_map_from(self):

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/structure/parent_old.so in
 sage.structure.parent_old.Parent._generic_convert_map
 (sage/structure/parent_old.c:6841)()
     594
     595
 --> 596
     597
     598

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/structure/parent_old.so in
 sage.structure.parent_old.Parent._generic_convert_map
 (sage/structure/parent_old.c:6806)()
     602
     603
 --> 604
     605
     606

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/structure/parent.so in
 sage.structure.parent.Parent._generic_convert_map
 (sage/structure/parent.c:6875)()
     747
     748
 --> 749
     750
     751

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/structure/coerce_maps.so in
 sage.structure.coerce_maps.DefaultConvertMap.__init__
 (sage/structure/coerce_maps.c:1931)()
      22
      23
 ---> 24
      25
      26

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/categories/map.so in sage.categories.map.Map.__init__
 (sage/categories/map.c:1768)()
      39
      40
 ---> 41
      42
      43

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/categories/homset.pyc in Hom(X, Y, cat)
     151
     152     ##_cache[key] = weakref.ref(H)
 --> 153     _cache[(X, Y, cat)] = weakref.ref(H)
     154
     155     return H

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/rings/number_field/number_field.pyc in __cmp__(self, other)
    1645         else:
    1646             return cmp(self.coerce_embedding()(self.gen()),
 -> 1647                        other.coerce_embedding()(other.gen()))
    1648
    1649     def _ideal_class_(self):

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/rings/real_lazy.so in
 sage.rings.real_lazy.LazyBinop.__richcmp__ (sage/rings/real_lazy.c:7864)()
     868
     869     def __richcmp__(left, right, int op):
 --> 870         return (<Element>left)._richcmp(right, op)
     871
     872     def __hash__(self):

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/structure/element.so in
 sage.structure.element.Element._richcmp (sage/structure/element.c:5167)()
     530
     531
 --> 532
     533
     534

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/structure/element.so in
 sage.structure.element.Element._richcmp_c_impl
 (sage/structure/element.c:5398)()
     577
     578
 --> 579
     580
     581

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/rings/real_lazy.so in
 sage.rings.real_lazy.LazyFieldElement._cmp_c_impl
 (sage/rings/real_lazy.c:5454)()
     508         except TypeError:
     509             pass
 --> 510         left, right = self.approx(), other.approx()
     511         return cmp(left, right)
     512

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/rings/real_lazy.so in
 sage.rings.real_lazy.LazyFieldElement.approx
 (sage/rings/real_lazy.c:5886)()
     567             Complex Interval Field with 53 bits of precision
     568         """
 --> 569         return self.eval(self._parent.interval_field())
     570
     571     def _real_double_(self, R):

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/rings/real_lazy.so in sage.rings.real_lazy.LazyBinop.eval
 (sage/rings/real_lazy.c:7433)()
     825             '68'
     826         """
 --> 827         left = self._left.eval(R)
     828         right = self._right.eval(R)
     829         if self._op is add:

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/rings/real_lazy.so in sage.rings.real_lazy.LazyBinop.eval
 (sage/rings/real_lazy.c:7445)()
     826         """
     827         left = self._left.eval(R)
 --> 828         right = self._right.eval(R)
     829         if self._op is add:
     830             return left + right

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/rings/real_lazy.so in
 sage.rings.real_lazy.LazyAlgebraic.eval (sage/rings/real_lazy.c:10512)()
    1292                 roots = self._poly.roots(ring = AA if
 isinstance(self._parent, RealLazyField_class) else QQbar)
    1293                 best_root = roots[0][0]
 -> 1294                 min_dist = abs(self._root_approx - best_root)
    1295                 for r, e in roots[1:]:
    1296                     dist = abs(self._root_approx - r)

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/structure/element.so in
 sage.structure.element.ModuleElement.__sub__
 (sage/structure/element.c:6075)()
     680
     681
 --> 682
     683
     684

 /Users/ncalexan/sage-3.2.1.alpha1/local/lib/python2.5/site-
 packages/sage/structure/coerce.so in
 sage.structure.coerce.CoercionModel_cache_maps.bin_op
 (sage/structure/coerce.c:5808)()
     695
     696
 --> 697
     698
     699

 TypeError: unsupported operand parent(s) for '-': 'Number Field in a with
 defining polynomial x^4 + 6*x^2 + 1' and 'Algebraic Field'
 sage: NumberField(x^4 + 6*x^2 + 1, 'a').extension(x^4 + 111, embeding=2.5)
 ---------------------------------------------------------------------------
 TypeError                                 Traceback (most recent call
 last)

 
/Users/ncalexan/.sage/temp/pv139196.reshsg.uci.edu/23733/_Users_ncalexan__sage_init_sage_0.py
 in <module>()
 ----> 1
       2
       3
       4
       5

 TypeError: extension() got an unexpected keyword argument 'embeding'
 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/4276#comment:18>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of 
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to