Skip to content

Commit

Permalink
Trac #24371: Move real/complex interval fields to new coercion model
Browse files Browse the repository at this point in the history
Also fix the following:
{{{
sage: NF.<a> = QuadraticField(-2)
sage: CIF(a)
...
ValueError: can not convert complex algebraic number to real interval
}}}

We also deal with Python 3 compatibility regarding `int`/`long` and
`bytes`/`unicode`.

URL: https://trac.sagemath.org/24371
Reported by: jdemeyer
Ticket author(s): Jeroen Demeyer
Reviewer(s): Travis Scrimshaw
  • Loading branch information
Release Manager authored and vbraun committed Feb 14, 2018
2 parents ee52455 + 9ac1612 commit 8a64691
Show file tree
Hide file tree
Showing 17 changed files with 732 additions and 553 deletions.
1 change: 0 additions & 1 deletion src/doc/en/reference/rings_numerical/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ ComplexBallField).
:maxdepth: 2

sage/rings/real_mpfi
sage/rings/real_interval_field
sage/rings/real_interval_absolute
sage/rings/complex_interval_field
sage/rings/complex_interval
Expand Down
2 changes: 2 additions & 0 deletions src/module_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,8 @@ def uname_specific(name, value, alternative):
Extension('sage.rings.ring',
sources = ['sage/rings/ring.pyx']),

Extension('*', ['sage/rings/convert/*.pyx']),

################################
##
## sage.rings.finite_rings
Expand Down
2 changes: 2 additions & 0 deletions src/sage/arith/constants.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ cdef extern from *:
double M_1_LN2 "0x1.71547652b82fep+0" # 1/log(2)
double M_1_LN10 "0x6.f2dec549b9438p-4" # 1/log(10)
double M_1_LNPI "0xd.fa22fdd8cfd98p-4" # 1/log(π)

double LOG_TEN_TWO_PLUS_EPSILON "0x3.5269e12f346e4p+0" # log(10,2) rounded up
3 changes: 0 additions & 3 deletions src/sage/categories/rings.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,9 +946,6 @@ def __getitem__(self, arg):
From: Number Field in i with defining polynomial x^2 + 1
To: Complex Lazy Field
Defn: i -> 1*I
sage: QQi.<i> = QuadraticField(-1, embedding=None)
sage: QQ[i].coerce_embedding() is None
True
TESTS:
Expand Down
15 changes: 9 additions & 6 deletions src/sage/rings/complex_interval.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@ from sage.libs.mpfr.types cimport mpfr_prec_t
from sage.libs.mpfi.types cimport mpfi_t

cimport sage.structure.element
from .real_mpfi cimport RealIntervalFieldElement
from .real_mpfi cimport RealIntervalFieldElement, RealIntervalField_class


cdef class ComplexIntervalFieldElement(sage.structure.element.FieldElement):
cdef mpfi_t __re
cdef mpfi_t __im
cdef mpfr_prec_t _prec

cpdef _add_(self, other)
cpdef _mul_(self, other)
cdef RealIntervalFieldElement abs_c(ComplexIntervalFieldElement self)
cdef RealIntervalFieldElement norm_c(ComplexIntervalFieldElement self)

cdef inline ComplexIntervalFieldElement _new(self):
"""
Quickly create a new complex interval with the same parent as
``self``.
"""
cdef type t = type(self)
return t.__new__(t, self._parent)

cdef inline RealIntervalFieldElement _new_real(self):
"""
Quickly create a new real interval with the same precision as
``self``.
"""
P = <RealIntervalField_class>(self._parent.real_field())
return P._new()
Loading

0 comments on commit 8a64691

Please sign in to comment.