Dear sage-devel, I'm a bit confused about what the recommended way to implement a free module is. In particular, I would like a custom parent and elements classes and coercion into the module. For simplicity, lets assume that speed is not an issue. It seems like there are at least three options:
1) Derive from one of the various classes in sage/modules/ free_module.py. Apparently requires cython if you want a custom element class as you have to override "cdef _new_c()". Fun fact: "FreeModule_generic_field.__init__()" does not work because of a base_ring vs. base_field typo. 2) Derive from CombinatorialFreeModule and CombinatorialFreeModuleElement from /sage/combinat/free_module.py. 3) Build your own using the categories framework. It seems to me that making something in the FiniteDimensionalModulesWithBasis category should be very concise, but I can't get it to work. The options 1) and 2) derive from ParentWithGens, which is deprecated (see comment at the top of sage/structure/parent_gens.pyx). Related is the following error: {{{ sage: F = CombinatorialFreeModule(QQ, ['a','b','c']) sage: F.gens() --------------------------------------------------------------------------- RuntimeError Traceback (most recent call last) /home/vbraun/opt/sage-4.5/devel/sage-main/<ipython console> in <module>() /home/vbraun/Sage/sage/local/lib/python2.6/site-packages/sage/ structure/parent_gens.so in sage.structure.parent_gens.ParentWithGens.gens (sage/structure/ parent_gens.c:2674)() /home/vbraun/Sage/sage/local/lib/python2.6/site-packages/sage/ structure/parent_gens.so in sage.structure.parent_gens.ParentWithGens.ngens (sage/structure/ parent_gens.c:2489)() /home/vbraun/Sage/sage/local/lib/python2.6/site-packages/sage/ structure/parent_gens.so in sage.structure.parent_gens.check_old_coerce (sage/structure/ parent_gens.c:1190)() RuntimeError: Free module generated by {'a', 'b', 'c'} over Rational Field still using old coercion framework }}} In 3) tried to derive from Parent but then how do I get MyClass.gen(int) and MyClass.gens()? Am I supposed to implement them manually? Best, Volker -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org