ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 01 Jul 2023 01:06:12 +0200Defining a graded vector spacehttps://ask.sagemath.org/question/69637/defining-a-graded-vector-space/Hello all. I'm trying to define a (finite) graded vector space using SAGE. I've managed to set up a class which takes names and degrees as input parameters.
Example:
My idea is that if we have names (x,y,z) with degrees (1,1,2), then this is supposed to be Q^2 + Q (taking the base ring to be Q). I am going to be building everything on the category of combinatorial free modules.
I have been struggling to define a method in the element class which is supposed to return the degree of a given expression by taking the maximum of the degrees of all the monomials. I have defined a dictionary (in the parent __init__ definition) which puts the name as key and degree as value. But how can I extract that information from any given arbitrary expression (say, B['x'] + B['y'])?
Example of successful code:
(y+z).degree()
sage: 2
Thanks in advance!adiSat, 01 Jul 2023 01:06:12 +0200https://ask.sagemath.org/question/69637/