Re: [sage-devel] coercion ZZ, QQ and quadratic number field

2013-05-10 Thread vdelecroix
Thanks for your answer. Le vendredi 10 mai 2013 22:15:37 UTC+2, David Roe a écrit : > > You can do: > > sage: K.=QuadraticField(2) > sage: K.register_coercion(K.coerce_map_from(QQ) * QQ.coerce_map_from(ZZ)) > > For even more speed you can write your own custom Cython coercion from ZZ > to K. > T

Re: [sage-devel] coercion ZZ, QQ and quadratic number field

2013-05-10 Thread David Roe
You can do: sage: K.=QuadraticField(2) sage: K.register_coercion(K.coerce_map_from(QQ) * QQ.coerce_map_from(ZZ)) For even more speed you can write your own custom Cython coercion from ZZ to K. David On Fri, May 10, 2013 at 12:59 PM, vdelecroix <20100.delecr...@gmail.com>wrote: > Hi, > > Let K

[sage-devel] coercion ZZ, QQ and quadratic number field

2013-05-10 Thread vdelecroix
Hi, Let K be a quadratic number field (let say K = QuadraticField(2)). There are "natural morphisms" implemented in Cython from ZZ to QQ and from QQ to K. There is also an other way, somewhat more direct, to go from ZZ to K. But at the end it is 10 times faster to go the first way and Sage does no