View Single Post
Old 2020-03-22, 03:04   #4
Aug 2019

11 Posts

We have something like below -

import ctypes

# load the library

# 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

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)


I got below error -

File "C:\Users\miron\Desktop\trash5\x\", line 68, in <module>
print( ellinit(h) )
File "C:\Users\miron\Desktop\trash5\x\", 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.
Andrew99 is offline   Reply With Quote