Hi, I would like to get some advice regarding the Parent/Element scheme. Consider the algebra C^oo(U) of smooth real-valued functions (scalar fields) U --> *R*, where U is an open subset of a smooth manifold over *R*. As discussed in this thread <https://groups.google.com/forum/#!topic/sage-devel/tVrqhKQ1QDs>, C^oo(U) is implemented in SageManifolds as a Parent in the category CommutativeAlgebras(SR). Following Volker's remark <https://groups.google.com/d/msg/sage-devel/tVrqhKQ1QDs/GM4YciuiiPgJ> about the subclass ZeroScalarField, I am wondering how to deal with constant scalar fields; there are two aspects:
- Technically, it would be desirable to create a subclass, ConstScalarField say, of the Element class of C^oo(U) (ScalarField) to implement constant fields, in order to take advantage of their specific properities: - their differentials are zero - evaluating their values at a given manifold point does not involve the point coordinates in some chart. Having a subclass allows one to call specific methods for the above operations, which is more efficient (e.g. no need to search for a chart in which both the point coordinates and the scalar field expression are known). - Mathematically, the set of constant scalar fields is a subalgebra of C^oo(U), so it would be natural to implement it as such. Is there any way to do this in the Parent/Element scheme ? Introducing the subclass ConstScalarField rises a number of questions, especially regarding the attribute element_class of the Parent (called hereafter CU, for C^oo(U)). As far as I understand, CU(x) shall return an instance of CU.element_class, which is a dynamically generated subclass of ScalarField (declared as Element=ScalarField in the class ScalarFieldAlgebra) and of the category parent class. Now, one would like CU(0) to return an instance of ConstScalarField (or a dynamically generated subclass of it), for the zero scalar field is clearly a constant one. Denoting by CCU the Parent of constant scalar fields, is it safe in CU._element_constructor_ to call CCU.element_class if x is constant, instead of CU.element_class ? In particular, CU(0).parent() would no longer be CU but CCU, which may result in some undesired effects... 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+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.