c++librariesparipari-gp

Pari/gp no matching function


I'm trying to configure pari to use on C++. Here's a code example showcasing my issue:

#include <pari/pari.h>

GEN d_field;
d_field = cgeti(5);
GEN upperLimit = exp(sqrt(log(d_field)));

Along with other similar errors for exp and sqrt, the compiler outputs: error: no matching function for call to ‘log(long int*&)’. VS code also highlights those functions. Curiously enough, GEN, cget etc. work just fine. What am I doing wrong? I installed pari through apt-get. in my CMakeList file I have:

...
add_compile_options(-Wall -Wpedantic -Werror -O0 -g -lpari -lm)
...
find_library(PARI_LIBRARY pari)
target_link_libraries(${TName}_${entry_point_name} ${PARI_LIBRARY})

What have I messed up?

I tried changing the flags in CMakeLists and looked online for a solution but couldnt find any problem similar to the one I'm experiencing.


Solution

  • Pari is a C library, which does not support multiple functions with the same name. You should look at the Pari documentation and use one of the correct functions from paridecl.h.

    I think the following functions can be composed, but you will have to figure out what precision you want:

    GEN     gexp(GEN x, long prec);
    GEN     glog(GEN x, long prec);
    GEN     gsqrt(GEN x, long prec);