On Nov 6, 2007, at 2:22 PM, William Stein wrote:

> On 11/6/07, Robert Bradshaw <[EMAIL PROTECTED]> wrote:
>> On Nov 6, 2007, at 1:59 PM, William Stein wrote:
>>
>>> Hi Robert (cc: sage-devel),
>>>
>>> Should the new coercion model address this sort of thing?
>>
>> Yes, it doesn't yet though, but shouldn't be too hard to add--the
>> construction method of ComplexField needs to be implemented.
>
> Please explain how to do this.  This will help other people start
> filling in the coercion implementations all over in Sage.

The construction method of a parent tells one how to "construct" the  
object out of more basic types. For example.

sage: RR.construction()
(CompletionFunctor, Rational Field)
sage: QQ.construction()
(FractionField, Integer Ring)
sage: Qp(7).construction()
(CompletionFunctor, Rational Field)
sage: QQ['x'].construction()
(PolynomialFunctor, Rational Field)

A.construction() returns a tuple F, B such that F(B) == A. Here F is  
an instance of sage.categories.pushout.ConstructionFunctor and B is  
another parent. F often caries other information with it (the __str__  
method could be made much more explicit for printing).

sage: F, B = RR.construction()
sage: F.prec
53
sage: F.p
+Infinity
sage: F.extras
{'rnd': 'RNDN', 'sci_not': False}

One can get a feel for this by playing with

sage: from sage.categories.pushout import construction_tower
sage: construction_tower(Qp(7)['x'][['y']])

[(None,
   Power Series Ring in y over Univariate Polynomial Ring in x over 7- 
adic Field with capped relative precision 20),
(CompletionFunctor,
   Univariate Polynomial Ring in y over Univariate Polynomial Ring in  
x over 7-adic Field with capped relative precision 20),
(PolynomialFunctor,
   Univariate Polynomial Ring in x over 7-adic Field with capped  
relative precision 20),
(PolynomialFunctor, 7-adic Field with capped relative precision 20),
(CompletionFunctor, Rational Field),
(FractionField, Integer Ring)]

The idea is that in computing a+b, the construction tower for parent 
(a) and parent(b) will be merged. The problem is that ComplexField  
(or CDF) does not have a construction.

sage: print CC.construction()
None

I suppose there should be an AlgebraicClosureFunctor that calls  
algebraic_closure() with no arguments (which, for the moment, would  
only be implemented for RR, RDF, RQDF). Then one would have

sage: print CC.construction()
AlgebraicClosureFunctor, Real Field with 53 bits of precision
sage: print CDF.construction()
AlgebraicClosureFunctor, Real Double Field
sage: print ComplexField(500).construction()
AlgebraicClosureFunctor, Real Field with 500 bits of precision

and stuff like RealField(100)(1) + ComplexField(200)(5) should work  
fine.

Well, that took longer to write up than implement, but this is the  
start of some documentation on the process, which needs to get done.

- Robert


--~--~---------~--~----~------------~-------~--~----~
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-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to