# Changeset 7425:c26b239c2e4e

Ignore:
Timestamp:
11/25/07 08:10:06 (6 years ago)
Branch:
default
Message:

Files:
7 edited

Unmodified
Removed
• ## sage/rings/all.py

 r6342 from complex_number import (is_ComplexNumber, create_ComplexNumber as ComplexNumber) Complexes = ComplexField from complex_interval_field import ComplexIntervalField, is_ComplexIntervalField from complex_interval import (is_ComplexIntervalFieldElement, create_ComplexIntervalFieldElement as ComplexIntervalFieldElement) from complex_double import ComplexDoubleField, ComplexDoubleElement, CDF, is_ComplexDoubleElement CC = ComplexField() CIF = ComplexIntervalField() I = CC.gen()
• ## sage/rings/complex_field.py

 r4057 from sage.structure.parent_gens import ParentWithGens NumberFieldElement_quadratic = None def late_import(): global NumberFieldElement_quadratic if NumberFieldElement_quadratic is None: import sage.rings.number_field.number_field_element_quadratic as nfeq NumberFieldElement_quadratic = nfeq.NumberFieldElement_quadratic def is_ComplexField(x): 0.333333333333333 + 2.00000000000000*I Note that the second argument is the number of *bits* of precision, not the number of digits of precision: sage: C(1/3, 2) 0.333333333333333 + 2.00000000000000*I We can also coerce rational numbers and integers into C, but coercing a polynomial in raising an exception. coercing a polynomial will raise an exception. sage: Q = RationalField() sage: CC(2,3) 2.00000000000000 + 3.00000000000000*I sage: CC(QQ[I].gen()) 1.00000000000000*I sage: CC.gen() + QQ[I].gen() Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '+': 'Complex Field with 53 bits of precision' and 'Number Field in I with defining polynomial x^2 + 1' """ if im is None: return complex_number.ComplexNumber(self, sage_eval(x.replace(' ',''), locals={"I":self.gen(),"i":self.gen()})) late_import() if isinstance(x, NumberFieldElement_quadratic) and list(x.parent().polynomial()) == [1, 0, 1]: (re, im) = list(x) return complex_number.ComplexNumber(self, re, im) try: return x._complex_mpfr_field_( self ) def scientific_notation(self, status=None): return self._real_field().scientific_notation(status)
• ## sage/rings/complex_number.pyx

 r5809 if imag is None: if real is None: return if PY_TYPE_CHECK(real, ComplexNumber): real, imag = (real).real(), (real).imag()
• ## sage/rings/mpfi.pxi

 r4843 int mpfi_has_zero(mpfi_srcptr) bint mpfi_has_zero(mpfi_srcptr) bint mpfi_nan_p(mpfi_srcptr)
• ## sage/rings/mpfr.pxi

 r6880 #int mpfr_pow_si _PROTO ((mpfr_ptr, mpfr_srcptr, long int, mp_rnd_t)); #int mpfr_min _PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mp_rnd_t)); #int mpfr_max _PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mp_rnd_t)); int mpfr_min (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mp_rnd_t) int mpfr_max (mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mp_rnd_t) int mpfr_fac_ui (mpfr_t rop, unsigned long int op, mp_rnd_t rnd) int mpfr_neg (mpfr_ptr rop, mpfr_srcptr op, mp_rnd_t rnd) # int mpfr_eq (mpfr_srcptr rop, mpfr_srcptr op, unsigned long i) int mpfr_cmp (mpfr_t op1, mpfr_t op2) bint mpfr_greater_p (mpfr_t op1, mpfr_t op2) bint mpfr_greaterequal_p (mpfr_t op1, mpfr_t op2) bint mpfr_less_p (mpfr_t op1, mpfr_t op2) bint mpfr_lessequal_p (mpfr_t op1, mpfr_t op2) int mpfr_cmp (mpfr_t op1, mpfr_t op2) bint mpfr_lessgreater_p (mpfr_t op1, mpfr_t op2) bint mpfr_equal_p (mpfr_t op1, mpfr_t op2) bint mpfr_unordered_p (mpfr_t op1, mpfr_t op2)
• ## sage/rings/real_mpfi.pyx

 r7244 ############################################################################ #***************************************************************************** # general TODOs: # # more type conversions and coercion. examples: # sage: R(1/2) # TypeError: Unable to convert x (='1/2') to mpfi. # # sage: 1 + R(42) # _49 = 1 #***************************************************************************** import math # for log import sys else: raise TypeError, "Canonical coercion from lower to higher precision not defined" if isinstance(x, (Integer, Rational, sage.rings.algebraic_real.AlgebraicRealNumber)): if isinstance(x, (Integer, Rational)): return self(x) cdef RealNumber lower, upper raise IndexError #    def complex_field(self): #        """ #        Return complex field of the same precision. #        """ #        return sage.rings.complex_field.ComplexField(self.prec()) def complex_field(self): """ Return complex field of the same precision. EXAMPLES: sage: RIF.complex_field() Complex Interval Field with 53 bits of precision """ return sage.rings.complex_interval_field.ComplexIntervalField(self.prec()) def ngens(self): return self.__prec # int mpfi_const_pi (mpfi_ptr) def pi(self): """ return x # int mpfi_const_euler (mpfi_ptr) def euler_constant(self): """ return x def is_exact(self): return mpfr_equal_p(&self.value.left, &self.value.right) def magnitude(self): """ return mpfr_lessequal_p(&rt.value.right, <.value.left) def __nonzero__(self): """ Returns true if self is not known to be exactly zero. EXAMPLES: sage: RIF(0).__nonzero__() False sage: RIF(1).__nonzero__() True sage: RIF(1, 2).__nonzero__() True sage: RIF(0, 1).__nonzero__() True sage: RIF(-1, 1).__nonzero__() True """ return not (mpfr_zero_p(&self.value.left) and mpfr_zero_p(&self.value.right)) def __cmp__(left, right): """ except TypeError, msg: return False def contains_zero(self): """ Returns True if self is an interval containing zero. EXAMPLES: sage: RIF(0).contains_zero() True sage: RIF(1, 2).contains_zero() False sage: RIF(-1, 1).contains_zero() True sage: RIF(-1, 0).contains_zero() True """ return mpfi_has_zero(self.value) def overlaps(self, RealIntervalFieldElement other): """ Returns true if self and other are intervals with at least one value in common.  For intervals a and b, we have a.overlaps(b) iff not(a!=b). EXAMPLES: sage: RIF(0, 1).overlaps(RIF(1, 2)) True sage: RIF(1, 2).overlaps(RIF(0, 1)) True sage: RIF(0, 1).overlaps(RIF(2, 3)) False sage: RIF(2, 3).overlaps(RIF(0, 1)) False sage: RIF(0, 3).overlaps(RIF(1, 2)) True sage: RIF(0, 2).overlaps(RIF(1, 3)) True """ return mpfr_greaterequal_p(&self.value.right, &other.value.left) \ and mpfr_greaterequal_p(&other.value.right, &self.value.left) def intersection(self, other): #             exponent = x._parent(exponent) #         return self.__pow(exponent) def __pow__(self, exponent, modulus): if isinstance(exponent, (int, long, Integer)): return sage.rings.ring_element.RingElement.__pow__(self, exponent) return (self.log() * exponent).exp() def log(self, base='e'):
• ## setup.py

 r7388 Extension('sage.rings.real_mpfi', sources = ['sage/rings/real_mpfi.pyx'], libraries = ['mpfi', 'mpfr', 'gmp']), \ Extension('sage.rings.complex_interval', sources = ['sage/rings/complex_interval.pyx'], libraries = ['mpfi', 'mpfr', 'gmp']), \
Note: See TracChangeset for help on using the changeset viewer.