![]() |
![]() |
#1 |
Aug 2019
11 Posts |
![]()
I want to use 4 specific functions of elliptic curve of PARI/GP found in the folder in \pari2.11.3\src\functions\elliptic_curves, this folder can be downloaded (Stable version: pari-2.11.3.tar.gz) from below link -
https://pari.math.u-bordeaux.fr/download.html But these functions do not have `.c` extension, but it is known that, PARI is a C library. I want use these function to call from python, so I need C version of these functions. So, where or how can I get C version of these functions? PS: When I say 4 specific functions, it could be any 4 from that folder, and exactly 4 of them, I hope, it is not important which 4 because procedure is same for all functions, also, I don't want use .dll file which has all the function. |
![]() |
![]() |
![]() |
#2 |
Aug 2006
3×1,987 Posts |
![]()
You can get the files from version control. Many of the functions, for example, are in src/basemath/elliptic.c.
But it's not trivial to pull the functions into Python, because the numbers aren't stored in the same format -- Python doesn't use PARI GENs. (This doesn't apply if you stick strictly to functions taking long and ulong values, and returning the same or void, but that won't apply to many elliptic functions.) You might consider using one ofto simplify this for you. If not, I suggest using gp2c to wrap the whole process from a declared long or ulong to your desired output to get at least a rough draft. |
![]() |
![]() |
![]() |
#3 | |
Aug 2019
11 Posts |
![]() Quote:
Could you plz guide me how to pass a vector/array into PARI using python by calling a finction of PARI through the use of ctypes? And do you have any information about the documents on cypari? Thanks. Last fiddled with by Andrew99 on 2020-03-22 at 02:57 |
|
![]() |
![]() |
![]() |
#4 |
Aug 2019
B16 Posts |
![]()
We have something like below -
import ctypes # load the library pari=ctypes.cdll.LoadLibrary("libpari.so") # set the right return type of the functions pari.stoi.restype = ctypes.POINTER(ctypes.c_long) pari.nextprime.restype = ctypes.POINTER(ctypes.c_long) # initialize the library pari.pari_init(2**19,0) def nextprime(v): g = pari.nextprime(pari.stoi(ctypes.c_long(v))) # nextprime(argument) is a PARI function return pari.itos(g) print( nextprime(456) ) For example I tried - h=(0,0,0, 4,6) pari.stoi.restype = ctypes.POINTER(ctypes.c_long*5) pari.ellinit.restype = ctypes.POINTER(ctypes.c_long) def ellinit(v): g = pari.ellinit(pari.stoi(ctypes.c_long(v)*5)) return pari.itos(g) print(ellinit(h)) I got below error - File "C:\Users\miron\Desktop\trash5\x\f.py", line 68, in <module> print( ellinit(h) ) File "C:\Users\miron\Desktop\trash5\x\f.py", line 62, in ellinit g = pari.ellinit(pari.stoi(ctypes.c_long(v)*5)) TypeError: an integer is required (got type tuple) How do I pass a tuple/array/vector? Thanks. |
![]() |
![]() |
![]() |
#5 |
Aug 2006
3×1,987 Posts |
![]()
This is not a simple question to answer for PARI in general (you get into issues of the stack and universal objects). But for what you are doing, the correct PARI code, I believe, is
Code:
retmkvec5(gen_0, gen_0, gen_0, utoipos(4), utoipos(6)) |
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Two variable functions | enzocreti | enzocreti | 7 | 2020-02-28 08:50 |
Posting log files or other text files | Xyzzy | Forum Feedback | 3 | 2018-12-30 19:37 |
Inverse of functions | Raman | Math | 5 | 2011-04-13 23:29 |
Return to failure functions | devarajkandadai | Miscellaneous Math | 3 | 2009-02-08 14:54 |
Busted functions | Dougy | Miscellaneous Math | 4 | 2006-02-22 20:59 |