hermann on Wed, 14 Jun 2023 11:57:02 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: How to best dynamically make use of cypari2?


On 2023-06-14 01:36, hermann@stamm-wilbrandt.de wrote:
...
There is one problem left, which could be fixed by applying Pari "lift()". But I needed to understand why "Mod(12, 19)" is returned, although function result types seem to be the wanted type for the two "to_...()" functions.
What is going on here? I don't see "cypari2.gen.Gen" ...

How can I make "to_sqrtm1(to_sum2sqs(12, 29), 29)" return just 12?


I found explanation

from cypari2_ import *
type(to_sum2sqs(12, 29))
pari
<class 'tuple'>
type(to_sum2sqs(12, 29)[0])
pari
<class 'cypari2.gen.Gen'>


as well as solution: use "gen_to_python()" to convert "Gen" result to Python type:
https://cypari2.readthedocs.io/en/latest/convert.html#cypari2.convert.gen_to_python


I updated the cypari2_.py gist, now it works as it should:
https://gist.github.com/Hermann-SW/f17e58b2df76b64da63e50e7402765e0

Type "help", "copyright", "credits" or "license" for more information.
from cypari2_ import *
to_sqrtm1((6, -5), 61)
11
to_sum2sqs(11, 61)
pari
(6, -5)
to_sqrtm1(to_sum2sqs(11, 61), 61)
pari
11
to_sum2sqs(to_sqrtm1((6, -5), 61), 61)
pari
(6, -5)



Regards,

Hermann.