Sep-01-2023, 11:26 AM
Finally got it working. The code below worked.
import ctypes as ct flib = ct.CDLL('euler.so') ode_spec = ct.CFUNCTYPE(None, ct.POINTER(ct.c_int), ct.POINTER(ct.c_float), ct.POINTER(ct.c_float * 1), ct.POINTER(ct.c_float * 1)) flib.euler_.restype = None flib.euler_.argtypes = [ ode_spec, ct.POINTER(ct.c_int), ct.POINTER(ct.c_float * 1), ct.POINTER(ct.c_float), ct.POINTER(ct.c_float), ct.POINTER(ct.c_float) ] @ode_spec def df(neq, t, y, dy): dy[0] = y[0] return t = ct.c_float(0.1) to = ct.c_float(0.2) neq = ct.c_int(1) relarr = ct.c_float * 1 y = relarr() y[0] = 0.1 h = ct.c_float(0.001) flib.euler_(df, ct.byref(neq) , ct.byref(y), ct.byref(t), ct.byref(to), ct.byref(h))