Dear All,
I started this conversation back in sage-combinat-devel but then Nicolas
correctly pointed out that this is something that should be discussed here.
Sorry for the repetition if you read both lists. 

Together with Dylan Rupel I am trying to implement cluster algebras as an
algebra and not as a collection of seeds at it is now. In order to do so I am
playing around with some "exotic" ways of using LaurentPolynomialRing and I
am getting a whole bunch of different issues. Here is an incomplete list of
them. 

Eventually I will like to implement a TropicalSemifiled and be able to pass
it as argument to LaurentPolynomialRing as follows:

sage: P = TropicalSemifield('y', 3)
sage: P 
Tropical semifield on the generators y0, y1, y2
sage: L = LaurentPolynomialRing(P,'x',3)
sage: L
Multivariate Laurent Polynomial Ring in x0, x1, x2 over Tropical Semifield on 
the generators y0, y1, y2

I did not implement this yet so, at the moment, I would be happy to substitute
P with 
sage: P = LaurentPolynomialRing(ZZ, 'y', 3)

Unfortunately, if one does that, there are few issues arising from how gcd
are computed; here is a small zoo of examples:

sage: P = LaurentPolynomialRing(ZZ, 'y', 3)
sage: P
Multivariate Laurent Polynomial Ring in y0, y1, y2 over Integer Ring
sage: L = LaurentPolynomialRing(P,'x',3)
sage: L
Multivariate Laurent Polynomial Ring in x0, x1, x2 over Multivariate Laurent 
Polynomial Ring in y0, y1, y2 over Integer Ring
sage: L.inject_variables()
Defining x0, x1, x2
sage: x0/x0
1
sage: x0.gcd(x0)
...
AttributeError: 
'sage.rings.polynomial.laurent_polynomial.LaurentPolynomial_mpair' object has 
no attribute 'gcd'
sage: gcd(x0,x0)
...
TypeError: unable to find gcd
sage: R = L.fraction_field()
sage: R.inject_variables()
Defining x0, x1, x2
sage: x0.gcd(x0)
1
sage: x0/x0
x0/x0
sage: _.denominator()
x0

Ok, I figured this was not the way to go. The next best thing would be to have 

sage: L = LaurentPolynomialRing(ZZ, 'x0,x1,x2,y0,y1,y2') 
sage: P = LaurentPolynomialRing(ZZ, 'y0,y1,y2')

but then:

sage: P.inject_variables()
Defining y0, y1, y2
sage: y0 in P
True
sage: y0 in L
False
sage: y0.parent().fraction_field()(y0) in L
True

Note that this is an issue of the multivariate implementation since 

sage: R = LaurentPolynomialRing(ZZ,'x,y') 
sage: T = LaurentPolynomialRing(ZZ,'y')
sage: T.inject_variables() 
Defining y 
sage: y in T 
True 
sage: y in R 
True 

as expected.

It looks to me that the implementation of LaurentPolynomialRing is full of
such corner case bugs and, if I understand correctly, it is still based on
the old architecture not the new Category/Parent/Element framework. Is there
any plan to replace it in the near future with a more modern implementation? 
Should I decide to invest time in improving it, would anyone here be 
interested to help? Do you have any suggestion/reference on how this should 
be done properly? I am relatively a newbie to all this so I might need as
many pointers as possible.
Thanks
S.


-- 
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.

Reply via email to