Last active
June 14, 2023 09:59
-
-
Save Hermann-SW/f17e58b2df76b64da63e50e7402765e0 to your computer and use it in GitHub Desktop.
Python script for testing making use of cypari2 if available
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sympy import gcd, I | |
try: | |
import cypari2 | |
pari = cypari2.Pari() | |
gen_to_python = cypari2.convert.gen_to_python | |
except ImportError: | |
cypari2 = None | |
if cypari2 is None: | |
def to_sum2sqs(sqrtm1, p): | |
return gcd(p, sqrtm1 + I).as_real_imag() | |
else: | |
def to_sum2sqs(sqrtm1, p): | |
print("pari") | |
[M, V] = pari.halfgcd(sqrtm1, p) | |
return gen_to_python(V[1]), gen_to_python(M[1, 0]) | |
def to_sqrtm1(xy, p): | |
return xy[0] * pow(xy[1], -1, p) % p |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does not neccessarily result in identity: