ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 16 Feb 2014 23:26:00 -0600which parent class for C-finite sequences?https://ask.sagemath.org/question/11017/which-parent-class-for-c-finite-sequences/Hello, I would like to embed a structure (C-finite sequences) in the Sage ring hierarchy. Fortunately, C-finite sequences are equivalent to the fractions of Laurent polynomials, any fraction is an ordinary generating function for a sequence, and it's a bijection. Now, I'm a bit confused as to the implementation procedure:
Can I just subclass the "right" ring class (FractionField?), and override the members. But which class? Can I create a specific ring class for Laurent polynomial fractions and just call it CFiniteSequenceRing? Maybe I don't even need a new ring, just a class for the elements? If so, is there a way to declare the bijection?
Given that there are P-finite sequences, a superset of the above, what should be done to ensure that they fit into the scheme?
Any hint would be welcome.
**Update:** It turned out that, in order to support combinatorial generating functions as well as multivariate generating functions, the ring of C-Finite Sequences should not be restricted, and the information which generator is associated with the ring element should be in the element. This makes the ring undistinguishable from an abstract fraction field. However, the elements are different from fraction field elements in that they contain more (and in the multivar case mandatory) information.Mon, 10 Feb 2014 05:07:10 -0600https://ask.sagemath.org/question/11017/which-parent-class-for-c-finite-sequences/Answer by rws for <p>Hello, I would like to embed a structure (C-finite sequences) in the Sage ring hierarchy. Fortunately, C-finite sequences are equivalent to the fractions of Laurent polynomials, any fraction is an ordinary generating function for a sequence, and it's a bijection. Now, I'm a bit confused as to the implementation procedure:</p>
<p>Can I just subclass the "right" ring class (FractionField?), and override the members. But which class? Can I create a specific ring class for Laurent polynomial fractions and just call it CFiniteSequenceRing? Maybe I don't even need a new ring, just a class for the elements? If so, is there a way to declare the bijection?</p>
<p>Given that there are P-finite sequences, a superset of the above, what should be done to ensure that they fit into the scheme?</p>
<p>Any hint would be welcome.</p>
<p><strong>Update:</strong> It turned out that, in order to support combinatorial generating functions as well as multivariate generating functions, the ring of C-Finite Sequences should not be restricted, and the information which generator is associated with the ring element should be in the element. This makes the ring undistinguishable from an abstract fraction field. However, the elements are different from fraction field elements in that they contain more (and in the multivar case mandatory) information.</p>
https://ask.sagemath.org/question/11017/which-parent-class-for-c-finite-sequences/?answer=16054#post-id-16054Given the updated question, I will simply create a subclass of FractionField, and call it RationalGeneratingFunctionField, overriding the methods that deal with elements. Please comment if you think this is stupid, or give a better answer.Sun, 16 Feb 2014 23:26:00 -0600https://ask.sagemath.org/question/11017/which-parent-class-for-c-finite-sequences/?answer=16054#post-id-16054