def _coerce_map_from_(self, S):
        """
        The rings that canonically coerce to the MPFR complex field are:

        - This MPFR complex field, or any other of higher precision

        - Anything that canonically coerces to the mpfr real field
          with this prec

        EXAMPLES::

            sage: ComplexField(200)(1) + RealField(90)(1) # indirect doctest
            2.0000000000000000000000000
            sage: parent(ComplexField(200)(1) + RealField(90)(1)) # indirect doctest
            Complex Field with 90 bits of precision
            sage: CC.0 + RLF(1/3) # indirect doctest
            0.333333333333333 + 1.00000000000000*I
            sage: ComplexField(20).has_coerce_map_from(CDF)
            True
            sage: ComplexField(200).has_coerce_map_from(CDF)
            False
        """
        RR = self._real_field()
        if RR.has_coerce_map_from(S):
            return complex_number.RRtoCC(RR, self) * RR._internal_coerce_map_from(S)
        if is_ComplexField(S) and S._prec >= self._prec:
            return self._generic_convert_map(S)
        late_import()
        if S in [AA, QQbar, CLF, RLF] or (S == CDF and self._prec <= 53):
            return self._generic_convert_map(S)
        return self._coerce_map_via([CLF], S)
Exemple #2
0
    def __init__(self, prec=53):
        """
        TESTS::

            sage: C = ComplexField(200)
            sage: C.category()
            Category of fields
            sage: TestSuite(C).run()
        """
        self._prec = int(prec)
        from sage.categories.fields import Fields
        ParentWithGens.__init__(self, self._real_field(), ('I',), False, category = Fields())
#        self._populate_coercion_lists_()
        self._populate_coercion_lists_(coerce_list=[complex_number.RRtoCC(self._real_field(), self)])
Exemple #3
0
    def __init__(self, prec=53):
        """
        Initialize ``self``.

        TESTS::

            sage: C = ComplexField(200)
            sage: C.category()
            Join of Category of fields and Category of complete metric spaces
            sage: TestSuite(C).run()
        """
        self._prec = int(prec)
        from sage.categories.fields import Fields
        ParentWithGens.__init__(self, self._real_field(), ('I',), False, category=Fields().Metric().Complete())
#        self._populate_coercion_lists_()
        self._populate_coercion_lists_(coerce_list=[complex_number.RRtoCC(self._real_field(), self)])