Thanks for your answer Vincent. I fully agree that having the field of real numbers in Sage would be nice !
Regards, Eric. Le mercredi 12 mars 2014 15:41:40 UTC+1, vdelecroix a écrit : > > Hi Eric, > > My first guess would be to modify the initialization of > CommutativeRing to authorize None as a valid input for base_ring. > > Now, the base_ring should be the ring with which you will describe > your functions. As functions are defined through coordinates in > charts, a natural candidate for the base ring would be the common ring > of the coordinate charts. > > I guess that right now, most examples are built upon the symbolic > ring. If you want a coordinate free definition, then you might hope > that somebody implements the field of real numbers and C^infinity(RR). > > Best > Vincent > > 2014-03-12 14:41 UTC+01:00, Eric Gourgoulhon > <egourg...@gmail.com<javascript:>>: > > > Hi, > > > > In order to treat tensor fields on a parallelizable domain N of some > smooth > > > > manifold as elements of a free module (cf. > > #15916<http://trac.sagemath.org/ticket/15916>and this > > post <https://groups.google.com/forum/#!topic/sage-devel/1QzUpHLUw_E>), > one > > > > has first to introduce the commutative ring C^oo(N) of smooth functions > N > > --> *R*, as a new class, ScalarFieldRing say. Browsing through Sage > > reference manual, a natural guess would be to make it a subclass of > > CommutativeRing: > > > > from sage.rings.ring import CommutativeRing > > class ScalarFieldRing(CommutativeRing): > > def __init__(self, domain): > > CommutativeRing.__init__(self, base_ring) > > self.domain = domain > > > > > > > > The issue here is that CommutativeRing.__init__ requires the argument > > "base_ring" and in the present context, I don't know what to put here: > the > > ring C^oo(N) does not depend upon any other ring. Shall I put self, i.e. > > write CommutativeRing.__init__(self, self) ? > > > > A second solution could be to declare ScalarFieldRing as a subclass of > > Ring, in the category of commutative rings: > > > > from sage.rings.ring import Ring > > from sage.categories.commutative_rings import CommutativeRings > > class ScalarFieldRing(Ring): > > def __init__(self, domain): > > Ring.__init__(self, None, category=CommutativeRings()) > > self.domain = domain > > > > > > > > Here the argument "base" of Ring.__init__ is set to None, which was not > > possible for the argument "base_ring" of CommutativeRing.__init__ : this > > triggered the error message "TypeError: base ring None is no commutative > > ring". > > > > A third solution is to declare ScalarFieldRing directly as a subclass of > > Parent, in the category of commutative rings: > > > > from sage.structure.parent import Parent > > from sage.categories.commutative_rings import CommutativeRings > > class ScalarFieldRing(Parent): > > def __init__(self, domain): > > Parent.__init__(self, category=CommutativeRings()) > > self.domain = domain > > > > > > > > Which solution is preferable (and why) ? (the three of them seem to > work, > > at least in the few tests I've performed). Thank you for your help. > > > > Eric. > > > > -- > > You received this message because you are subscribed to the Google > Groups > > "sage-devel" group. > > To unsubscribe from this group and stop receiving emails from it, send > an > > email to sage-devel+...@googlegroups.com <javascript:>. > > To post to this group, send email to > > sage-...@googlegroups.com<javascript:>. > > > Visit this group at http://groups.google.com/group/sage-devel. > > For more options, visit https://groups.google.com/d/optout. > > > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.