hermann on Wed, 14 Jun 2023 01:40:52 +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-13 22:55, Vincent Delecroix wrote:
A more pythonic way is

try:
   import cypari2
except ImportError:
   cypari2 = None

if cypari2 is None:
    # cypari2 not available
    ...
else:
    # cypari2 is available
    ...

Thank you, I buy that pythonic way.


Before updating RSA_numbers_factored repo, I mmodified previous script
for the pythonic way in "cypari2_.py":
https://gist.github.com/Hermann-SW/f17e58b2df76b64da63e50e7402765e0

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?


Type "help", "copyright", "credits" or "license" for more information.
from cypari2_ import *
to_sum2sqs(12, 29)
pari
(5, -2)
to_sqrtm1((5, -2), 29)
12
to_sum2sqs(to_sqrtm1((2,5), 29), 29)
pari
(5, -2)
to_sqrtm1(to_sum2sqs(12, 29), 29)
pari
Mod(12, 29)
type(to_sum2sqs(12, 29))
pari
<class 'tuple'>
type(to_sqrtm1((5, -2), 29))
<class 'int'>



Regards,

Hermann.