hermann on Mon, 15 Sep 2025 11:50:22 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Using Pari from within a C program |
On 2025-09-15 09:35, Gordon Royle wrote:
I am aware that there is documentation concerning the use of Pari as a library and how to incorporate it into a C program,
and that documentation is really good: https://pari.math.u-bordeaux.fr/pub/pari/manuals/2.17.2/libpari.pdf
but in this situation (described below), I don't have full control over the C program and I don't understand where to put things like the Pari initialisation code. Anyway, here is the setup. I am writing a single function in C that has a fixed prototype that is to be called hundreds of millions of times as a "plugin" in a larger program.
What you definitely need in addition is: #include <pari/pari.h>I did need Karim's conversion function "mpz2GEN(mpz_t X)" as well in order to convert gmp number to PARI number format, both in "#ifdef PARI":
https://github.com/Hermann-SW/RSA_numbers_factored/blob/main/c%2B%2B/sqrtm1.smallest_known_1million_digit_prime.cc#L19-L40 Here you can see how the pari initialization code is used: https://github.com/Hermann-SW/RSA_numbers_factored/blob/main/c%2B%2B/sqrtm1.smallest_known_1million_digit_prime.cc#L68-L93The commented out asserts demonstrate some PARI types you will have to use as well.
Regards, Hermann.