Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

subclass from a sage vector

Hello all,

I have another question regarding the vector class shipped with sage. I would like to add some properties to a vector to store some additional information. But I am not sure which class I should choose as a base class, since there are a lot of different vector classes:

sage: type(vector([1.123,324.1]))
<type 'sage.modules.free_module_element.FreeModuleElement_generic_dense'>
sage: type(vector([1,2]))        
<type 'sage.modules.vector_integer_dense.Vector_integer_dense'>
sage: type(vector([1,6/2]))
<type 'sage.modules.vector_rational_dense.Vector_rational_dense'>

Do I have to pick one of those classes (I excpect a real vector would to ok) or is it possible to subclass in such a way that I can have different base_ring()s for my class?

subclass from a sage vector

Hello all,

I have another question regarding the vector class shipped with sage. I would like to add some properties to a vector to store some additional information. But I am not sure which class I should choose as a base class, since there are a lot of different vector classes:

sage: type(vector([1.123,324.1]))
<type 'sage.modules.free_module_element.FreeModuleElement_generic_dense'>
sage: type(vector([1,2]))        
<type 'sage.modules.vector_integer_dense.Vector_integer_dense'>
sage: type(vector([1,6/2]))
<type 'sage.modules.vector_rational_dense.Vector_rational_dense'>

Do I have to pick one of those classes (I excpect a real vector would to ok) do OK) or is it possible to subclass in such a way that I can have different base_ring()s for my class?