Max Alekseyev on Mon, 19 Jun 2023 01:24:28 +0200


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

Re: void mpz_set_GEN(mpz_ptr z, GEN x) and GEN mpz_get_GEN(mpz_srcptr z)


For the time being I've been using the code from Karim, which is available at
https://pari.math.u-bordeaux.fr/archives/pari-users-0712/msg00001.html

Regards,
Max

On Sun, Jun 18, 2023 at 6:57 PM <hermann@stamm-wilbrandt.de> wrote:
Until now I wrote GP scripts.
Now I did write my first C++ with libgmpxx and PARI code.

I did need to convert between t_INT GEN and libgmpxx mpz_t in both
directions.
I found subject functions in this posting ...
https://mersenneforum.org/showpost.php?s=1b4a66ceb4c359463161f3d6451771c4&p=626367&postcount=13

and made use of them to create GEN ...
https://github.com/Hermann-SW/RSA_numbers_factored/blob/main/c%2B%2B/sqrtm1.smallest_known_1million_digit_prime.cc#L105-L106

and copy from GEN:
https://github.com/Hermann-SW/RSA_numbers_factored/blob/main/c%2B%2B/sqrtm1.smallest_known_1million_digit_prime.cc#L120-L121

Those functions are not part of PARI, has one to use such self-coded
functions for the job?

Regards,

Hermann.


c++$ g++ $f.cc -lgmp -lgmpxx -O3 -o $f -lpari -DPARI
c++$ ./sqrtm1.smallest_known_1million_digit_prime
a = y^(-1) (mod p) [powm]; a *= x; a %= x
0.252741s
[M,V] = halfgcdii(sqrtm1, p)
0.268554s
[x,y] = [V[2], M[2,1]]
3.4e-05s
done
c++$