def cast(obj, typ):
return _cast(obj, obj, typ)
def cvLoadCast(filename, ctype):
'''Use cvLoad and then cast the result to ctype'''
return ctypes.cast(cvLoad(filename), ctypes.POINTER(ctype))
# --- 5 Miscellaneous Functions ----------------------------------------------
def ChangeCvSeqToCvRect(result, func, args):
'''Handle the casting to extract a list of Rects from the Seq returned'''
res = []
for i in xrange(result[0].total):
f = cvGetSeqElem(result, i)
r = ctypes.cast(f, ctypes.POINTER(CvRect))[0]
res.append(r)
src/p/y/pysundials-HEAD/2.3.0/examples/cvodes/serial/cvsadjdenx.py pysundials(Download)
def f(t, y, ydot, f_data): data = ctypes.cast(f_data, PUserData) yd1 = ydot[0] = -data.contents.p[0]*y[0] + data.contents.p[1]*y[1]*y[2] yd3 = ydot[2] = data.contents.p[2]*y[1]*y[1] ydot[1] = -yd1 - yd3 return 0 def Jac(N, J, t, y, fy, jac_data, tmp1, tmp2, tmp3): data = ctypes.cast(jac_data, PUserData)
def fB(t, y, yB, yBdot, f_dataB): data = ctypes.cast(f_dataB, PUserData) l21 = yB[1]-yB[0] l32 = yB[2]-yB[1] y23 = y[1]*y[2] yBdot[0] = -data.contents.p[0]*l21 yBdot[1] = data.contents.p[1]*y[2]*l21 - 2.0*data.contents.p[2]*y[1]*l32 yBdot[2] = data.contents.p[1]*y[1]*l21 - 1.0 return 0 def JacB(NB, JB, t, y, yB, fyB, jac_dataB, tmp1B, tmp2B, tmp3B): data = ctypes.cast(jac_dataB, PUserData)
def fQB(t, y, yB, qBdot, fQ_dataB): data = ctypes.cast(fQ_dataB, PUserData) l21 = yB[1]-yB[0]; l32 = yB[2]-yB[1]; y23 = y[1]*y[2];
src/p/y/pysundials-HEAD/2.3.0/examples/cvode/serial/cvbanx.py pysundials(Download)
def f(t, u, udot, f_data): data = ctypes.cast(f_data, ctypes.POINTER(userdata)) hordc = data.contents.hdcoef horac = data.contents.hacoef verdc = data.contents.vdcoef for j in range(5):
def Jac(N, mu, ml, J, t, u, fu, jac_data, tmp1, tmp2, tmp3): data = ctypes.cast(jac_data, ctypes.POINTER(userdata)) hordc = data.contents.hdcoef horac = data.contents.hacoef verdc = data.contents.vdcoef for j in range(5):
src/p/y/pysundials-HEAD/2.3.0/examples/cvodes/serial/cvsbanx.py pysundials(Download)
def Jac(N, mu, ml, J, t, u, fu, jac_data, tmp1, tmp2, tmp3): data = ctypes.cast(jac_data, PUserData) hordc = data.contents.hdcoef horac = data.contents.hacoef verdc = data.contents.vdcoef for j in range(5):
src/r/t/rtree-HEAD/rtree/index.py rtree(Download)
ctypes.byref(dimension))
if (dimension.value == 0): return None
mins = ctypes.cast(pp_mins,ctypes.POINTER(ctypes.c_double \
* dimension.value))
maxs = ctypes.cast(pp_maxs,ctypes.POINTER(ctypes.c_double \
* dimension.value))
results = [mins.contents[i] for i in range(dimension.value)]
results += [maxs.contents[i] for i in range(dimension.value)]
p_mins = ctypes.cast(mins,ctypes.POINTER(ctypes.c_double))
p_maxs = ctypes.cast(maxs,ctypes.POINTER(ctypes.c_double))
core.rt.Index_Free(ctypes.cast(p_mins, ctypes.POINTER(ctypes.c_void_p)))
p_mins = ctypes.cast(mins,ctypes.POINTER(ctypes.c_double))
p_maxs = ctypes.cast(maxs,ctypes.POINTER(ctypes.c_double))
core.rt.Index_Free(ctypes.cast(p_mins, ctypes.POINTER(ctypes.c_void_p)))
core.rt.Index_Free(ctypes.cast(p_maxs, ctypes.POINTER(ctypes.c_void_p)))
if interleaved: # they want bbox order.
return results
return Index.deinterleave(results)
def _get_data(handle):
length = ctypes.c_uint64(0)
d = ctypes.pointer(ctypes.c_uint8(0))
core.rt.IndexItem_GetData(handle, ctypes.byref(d), ctypes.byref(length))
c = ctypes.cast(d, ctypes.POINTER(ctypes.c_void_p))
p = ctypes.pointer(d)
# return serialized to keep it alive for the pointer.
return size, ctypes.cast(p, ctypes.POINTER(ctypes.c_uint8)), serialized
def insert(self, id, coordinates, obj = None):
"""Inserts an item into the index with the given coordinates.
def _get_objects(self, it, num_results, objects):
# take the pointer, yield the result objects and free
items = ctypes.cast(it, ctypes.POINTER(ctypes.POINTER(ctypes.c_void_p * num_results)))
its = ctypes.cast(items, ctypes.POINTER(ctypes.POINTER(ctypes.c_void_p)))
try:
if objects != 'raw':
def _get_ids(self, it, num_results):
# take the pointer, yield the results and free
items = ctypes.cast(it, ctypes.POINTER(ctypes.c_uint64 * num_results))
its = ctypes.cast(items, ctypes.POINTER(ctypes.c_void_p))
try:
for i in xrange(num_results):
darray = ctypes.c_double * dimension
mins = darray()
maxs = darray()
no_data = ctypes.cast(ctypes.pointer(ctypes.c_ubyte(0)),
ctypes.POINTER(ctypes.c_ubyte))
def py_next_item(p_id, p_mins, p_maxs, p_dimension, p_data, p_length):
mins[i] = coordinates[i*2]
maxs[i] = coordinates[(i*2)+1]
p_mins[0] = ctypes.cast(mins, ctypes.POINTER(ctypes.c_double))
p_maxs[0] = ctypes.cast(maxs, ctypes.POINTER(ctypes.c_double))
# set the dimension
p_dimension[0] = dimension
if obj is None:
p_data[0] = no_data
p_length[0] = 0
else:
p_length[0], data, _ = self._serialize(obj)
p_data[0] = ctypes.cast(data, ctypes.POINTER(ctypes.c_ubyte))
output = []
count = leaf_node_count.value
sizes = ctypes.cast(p_leafsizes, ctypes.POINTER(ctypes.c_uint32 * count))
ids = ctypes.cast(p_leafids, ctypes.POINTER(ctypes.c_int64 * count))
child = ctypes.cast(pp_childids, ctypes.POINTER(ctypes.POINTER(ctypes.c_int64) * count))
mins = ctypes.cast(pp_mins, ctypes.POINTER(ctypes.POINTER(ctypes.c_double) * count))
maxs = ctypes.cast(pp_maxs, ctypes.POINTER(ctypes.POINTER(ctypes.c_double) * count))
for i in range(count):
p_child_ids = child.contents[i]
id = ids.contents[i]
size = sizes.contents[i]
child_ids_array = ctypes.cast(p_child_ids, ctypes.POINTER(ctypes.c_int64 * size))
child_ids.append(child_ids_array.contents[j])
# free the child ids list
core.rt.Index_Free(ctypes.cast(p_child_ids, ctypes.POINTER(ctypes.c_void_p)))
p_mins = mins.contents[i]
p_maxs = maxs.contents[i]
p_mins = ctypes.cast(p_mins, ctypes.POINTER(ctypes.c_double * dimension.value))
p_maxs = ctypes.cast(p_maxs, ctypes.POINTER(ctypes.c_double * dimension.value))
bounds += [p_maxs.contents[i] for i in range(dimension.value)]
# free the bounds
p_mins = ctypes.cast(p_mins,ctypes.POINTER(ctypes.c_double))
p_maxs = ctypes.cast(p_maxs,ctypes.POINTER(ctypes.c_double))
core.rt.Index_Free(ctypes.cast(p_mins, ctypes.POINTER(ctypes.c_void_p)))
core.rt.Index_Free(ctypes.cast(p_maxs, ctypes.POINTER(ctypes.c_void_p)))
src/r/t/Rtree-0.6.0/rtree/index.py Rtree(Download)
ctypes.byref(dimension))
if (dimension.value == 0): return None
mins = ctypes.cast(pp_mins,ctypes.POINTER(ctypes.c_double \
* dimension.value))
maxs = ctypes.cast(pp_maxs,ctypes.POINTER(ctypes.c_double \
* dimension.value))
results = [mins.contents[i] for i in range(dimension.value)]
results += [maxs.contents[i] for i in range(dimension.value)]
p_mins = ctypes.cast(mins,ctypes.POINTER(ctypes.c_double))
p_maxs = ctypes.cast(maxs,ctypes.POINTER(ctypes.c_double))
core.rt.Index_Free(ctypes.cast(p_mins, ctypes.POINTER(ctypes.c_void_p)))
p_mins = ctypes.cast(mins,ctypes.POINTER(ctypes.c_double))
p_maxs = ctypes.cast(maxs,ctypes.POINTER(ctypes.c_double))
core.rt.Index_Free(ctypes.cast(p_mins, ctypes.POINTER(ctypes.c_void_p)))
core.rt.Index_Free(ctypes.cast(p_maxs, ctypes.POINTER(ctypes.c_void_p)))
if interleaved: # they want bbox order.
return results
return Index.deinterleave(results)
def _get_data(handle):
length = ctypes.c_uint64(0)
d = ctypes.pointer(ctypes.c_uint8(0))
core.rt.IndexItem_GetData(handle, ctypes.byref(d), ctypes.byref(length))
c = ctypes.cast(d, ctypes.POINTER(ctypes.c_void_p))
p = ctypes.pointer(d)
# return serialized to keep it alive for the pointer.
return size, ctypes.cast(p, ctypes.POINTER(ctypes.c_uint8)), serialized
def insert(self, id, coordinates, obj = None):
"""Inserts an item into the index with the given coordinates.
def _get_objects(self, it, num_results, objects):
# take the pointer, yield the result objects and free
items = ctypes.cast(it, ctypes.POINTER(ctypes.POINTER(ctypes.c_void_p * num_results)))
its = ctypes.cast(items, ctypes.POINTER(ctypes.POINTER(ctypes.c_void_p)))
try:
if objects != 'raw':
def _get_ids(self, it, num_results):
# take the pointer, yield the results and free
items = ctypes.cast(it, ctypes.POINTER(ctypes.c_uint64 * num_results))
its = ctypes.cast(items, ctypes.POINTER(ctypes.c_void_p))
try:
for i in xrange(num_results):
darray = ctypes.c_double * dimension
mins = darray()
maxs = darray()
no_data = ctypes.cast(ctypes.pointer(ctypes.c_ubyte(0)),
ctypes.POINTER(ctypes.c_ubyte))
def py_next_item(p_id, p_mins, p_maxs, p_dimension, p_data, p_length):
mins[i] = coordinates[i*2]
maxs[i] = coordinates[(i*2)+1]
p_mins[0] = ctypes.cast(mins, ctypes.POINTER(ctypes.c_double))
p_maxs[0] = ctypes.cast(maxs, ctypes.POINTER(ctypes.c_double))
# set the dimension
p_dimension[0] = dimension
if obj is None:
p_data[0] = no_data
p_length[0] = 0
else:
p_length[0], data, _ = self._serialize(obj)
p_data[0] = ctypes.cast(data, ctypes.POINTER(ctypes.c_ubyte))
output = []
count = leaf_node_count.value
sizes = ctypes.cast(p_leafsizes, ctypes.POINTER(ctypes.c_uint32 * count))
ids = ctypes.cast(p_leafids, ctypes.POINTER(ctypes.c_int64 * count))
child = ctypes.cast(pp_childids, ctypes.POINTER(ctypes.POINTER(ctypes.c_int64) * count))
mins = ctypes.cast(pp_mins, ctypes.POINTER(ctypes.POINTER(ctypes.c_double) * count))
maxs = ctypes.cast(pp_maxs, ctypes.POINTER(ctypes.POINTER(ctypes.c_double) * count))
for i in range(count):
p_child_ids = child.contents[i]
id = ids.contents[i]
size = sizes.contents[i]
child_ids_array = ctypes.cast(p_child_ids, ctypes.POINTER(ctypes.c_int64 * size))
child_ids.append(child_ids_array.contents[j])
# free the child ids list
core.rt.Index_Free(ctypes.cast(p_child_ids, ctypes.POINTER(ctypes.c_void_p)))
p_mins = mins.contents[i]
p_maxs = maxs.contents[i]
p_mins = ctypes.cast(p_mins, ctypes.POINTER(ctypes.c_double * dimension.value))
p_maxs = ctypes.cast(p_maxs, ctypes.POINTER(ctypes.c_double * dimension.value))
bounds += [p_maxs.contents[i] for i in range(dimension.value)]
# free the bounds
p_mins = ctypes.cast(p_mins,ctypes.POINTER(ctypes.c_double))
p_maxs = ctypes.cast(p_maxs,ctypes.POINTER(ctypes.c_double))
core.rt.Index_Free(ctypes.cast(p_mins, ctypes.POINTER(ctypes.c_void_p)))
core.rt.Index_Free(ctypes.cast(p_maxs, ctypes.POINTER(ctypes.c_void_p)))
src/p/y/pysces-HEAD/trunk/pysces_pysundials/pysundials/cvodes.py pysces(Download)
def WrapCallbackCVRhsFn(func):
"""Returns a callback wrapper around the given python callable object (func). This function should never be called directly, as it is called implicitly by any functions that specify a RHS function.\n\nThe callable python objet must takes exactly 4 parameters, which will be passed in as\n\ttime_step (float)\n\ty (NVector)\n\tydot (NVector)\n\tf_data (c_void_p)\n\nand must return an integer of 0 in the case of no error, otherwise a user defined integer indicating an error condition."""
if func == None:
return ctypes.cast(None, CVRhsFn)
exec 'def __CallbackInterface_%s(t, y, ydot, f_data):\n\treturn __ActualCallback[%i](t, nvecserial.NVector(y), nvecserial.NVector(ydot), f_data)'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVRhsFn(eval("__CallbackInterface_%s"%(func.func_name)))
def WrapCallbackCVRootFn(func):
"""Returns a callback wrapper around the given python callable object (func). This function should never be called directly, as it is called implicitly by any functions that specify a root finding function.\n\nThe callable python objet must takes exactly 4 parameters, which will be passed in as\n\ttime_step (float)\n\ty (NVector)\n\tgout (NVector)\n\tg_data (c_void_p)\n\nand must return an integer of 0 in the case of no error, otherwise a user defined integer indicating an error condition."""
if func == None:
return ctypes.cast(None, CVRootFn)
exec 'def __CallbackInterface_%s(t, y, gout, g_data):\n\treturn __ActualCallback[%i](t, nvecserial.NVector(y), gout, g_data)'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVRootFn(eval("__CallbackInterface_%s"%(func.func_name)))
def WrapCallbackCVEwtFn(func):
"""Returns a callback wrapper around the given python callable object (func). This function should never be called directly, as it is called implicitly by any functions that specify an error weight function.\n\nThe callable python objet must takes exactly 3 parameters, which will be passed in as\n\ty (NVector)\n\tewt (NVector)\n\te_data (c_void_p)\n\nand must return an integer of 0 in the case of no error, otherwise a user defined integer indicating an error condition."""
if func == None:
return ctypes.cast(None, CVEwtFn)
exec 'def __CallbackInterface_%s(y, ewt, e_data):\n\treturn __ActualCallback[%i](nvecserial.NVector(y), nvecserial.NVector(ewt), e_data)'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVEwtFn(eval("__CallbackInterface_%s"%(func.func_name)))
def WrapCallbackCVErrHandlerFn(func):
"""Creates a wrapper around a python callable object, that can be used as a callback for the error handler function. Error handler functions take error_code (int), module (string), function_name (string), message (string), and eh_data (c_void_p) as parameters, and have no return value."""
if func == None:
return ctypes.cast(None, CVErrHandlerFn)
exec 'def __CallbackInterface_%s(error_code, module, function, msg, eh_data):\n\treturn __ActualCallback[%i](error_code, module, function, msg, eh_data)'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVErrHandlerFn(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
return tmp
CVQuadRhsFn = ctypes.CFUNCTYPE(ctypes.c_int, realtype, ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.c_void_p)
def WrapCallbackCVQuadRhsFn(func):
if func == None:
return ctypes.cast(None, CVQuadRhsFn)
def WrapCallbackCVSensRhsFn(func):
if func == None:
return ctypes.cast(None, CVSensRhsFn)
exec 'def __CallbackInterface_%s(Ns, t, y, ydot, yS, ySdot, fS_data, tmp1, tmp2):\n\treturn __ActualCallback[%i](Ns, t, nvecserial.NVector(y), nvecserial.NVector(ydot), nvecserial.NVector(yS), nvecserial.NVector(ySdot), fS_data, nvecserial.NVector(tmp1), nvecserial.NVector(tmp2))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVSensRhsFn(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
return tmp
CVSensRhs1Fn = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int, realtype, ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.c_int, ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.c_void_p, ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector))
def WrapCallbackCVSensRhs1Fn(func):
if func == None:
return ctypes.cast(None, CVSensRhs1Fn)
def WrapCallbackCVRhsFnB(func):
if func == None:
return ctypes.cast(None, CVRhsFnB)
exec 'def __CallbackInterface_%s(t, y, yB, yBdot, f_dataB):\n\treturn __ActualCallback[%i](t, nvecserial.NVector(y), nvecserial.NVector(yB), nvecserial.NVector(yBdot), f_dataB)'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVRhsFnB(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
return tmp
CVQuadRhsFnB = ctypes.CFUNCTYPE(ctypes.c_int, realtype, ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.c_void_p)
def WrapCallbackCVQuadRhsFnB(func):
if func == None:
return ctypes.cast(None, CVQuadRhsFnB)
def WrapCallbackATimesFn(func):
if (func == None):
return ctypes.cast(None, ATimesFn)
exec 'def __CallbackInterface_%s(A_data, v, z):\n\treturn __ActualCallback[%i](A_data, nvecserial.NVector(v), nvecserial.NVector(z))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = ATimesFn(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
return tmp
PSolveFn = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.c_int)
def WrapCallbackPSolveFn(func):
if (func == None):
return ctypes.cast(None, PSolveFn)
def WrapCallbackCVLocalFn(func):
"""Creates a wrapper around a python callable object, that can be used as a callback for the local approximation RHS function. Local approximation RHS functions take Nlocal (int = size of local vector), time_step (float), y (NVector), g (NVector), and f_data (c_void_p) as parameters, and return an integer."""
if func == None:
return ctypes.cast(None, CVLocalFn)
exec 'def __CallbackInterface_%s(Nlocal, t, y, g, f_data):\n\treturn __ActualCallback[%i](Nlocal, t, nvecserial.NVector(y), nvecserial.NVector(g), f_data)'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVLocalFn(eval("__CallbackInterface_%s"%(func.func_name)))
def WrapCallbackCVCommFn(func):
"""Creates a wrapper around a python callable object, that can be used to perform all IPC necessary to approximate the RHS function. Such functions take Nlocal (int = size of local vector), time_step (float), y (NVector), and f_data (c_void_p) as parameters, and return nothing."""
if func == None:
return ctypes.cast(None, CVCommFn)
exec 'def __CallbackInterface_%s(Nlocal, t, y, f_data):\n\treturn __ActualCallback[%i](Nlocal, t, nvecserial.NVector(y), f_data)'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVCommFn(eval("__CallbackInterface_%s"%(func.func_name)))
def WrapCallbackCVLocalFnB(func):
exec 'def __CallbackInterface_%s(NlocalB, t, y, yB, gB, f_dataB):\n\treturn __ActualCallback[%i](NlocalB, t, nvecserial.NVector(y), nvecserial.NVector(yB), nvecserial.NVector(gB), f_dataB)'%(func.func_name, len(__ActualCallback))
if func == None:
return ctypes.cast(None, CVLocalFnB)
__ActualCallback.append(func)
tmp = CVLocalFnB(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
return tmp
CVCommFnB = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_long, realtype, ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.c_void_p)
def WrapCallbackCVCommFnB(func):
exec 'def __CallbackInterface_%s(NlocalB, t, y, yB, f_dataB):\n\treturn __ActualCallback[%i](NlocalB, t, nvecserial.NVector(y), nvecserial.NVector(yB), f_dataB)'%(func.func_name, len(__ActualCallback))
if func == None:
return ctypes.cast(None, CVCommFnB)
def WrapCallbackCVBandJacFn(func):
"""Creates a wrapper around a python callable object, that can be used as a callback for the Jacobian function. Jacobian functions for banded matrices take N (int = dimension of matrix), muppper (int = upper band width), mlower (int = lower band width), t (float = time step), J (BandMat = Jacobian Matrix), y (NVector), fy (NVector), jac_data (c_void_p), tmp1 (NVector), tmp2 (NVector), and tmp3 (NVector) as parameters, and return an integer."""
if func == None:
return ctypes.cast(None, CVBandJacFn)
exec 'def __CallbackInterface_%s(N, mupper, mlower, J, t, y, fy, jac_data, tmp1, tmp2, tmp3):\n\treturn __ActualCallback[%i](N, mupper, mlower, BandMat(J), t, nvecserial.NVector(y), nvecserial.NVector(fy), jac_data, nvecserial.NVector(tmp1), nvecserial.NVector(tmp2), nvecserial.NVector(tmp3))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVBandJacFn(eval("__CallbackInterface_%s"%(func.func_name)))
def WrapCallbackCVBandJacFnB(func):
exec 'def __CallbackInterface_%s(nB, mupperB, mlowerB, JB, t, y, yB, fyB, jac_dataB, tmp1B, tmp2B, tmp3B):\n\treturn __ActualCallback[%i](nB, mupperB, mlowerB, BandMat(JB), t, nvecserial.NVector(y), nvecserial.NVector(yB), nvecserial.NVector(fyB), jac_dataB, nvecserial.NVector(tmp1B), nvecserial.NVector(tmp2B), nvecserial.NVector(tmp3B))'%(func.func_name, len(__ActualCallback))
if func == None:
return ctypes.cast(None, CVBandJacFnB)
__ActualCallback.append(func)
tmp = CVBandJacFnB(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
def WrapCallbackCVDenseJacFn(func):
"""Creates a wrapper around a python callable object, that can be used as a callback for the Jacobian function. Jacobian functions for dense matrices take N (int = dimension of matrix), J (DenseMat = Jacobian Matrix), t (float = time step), y (NVector), fy (NVector), jac_data (c_void_p), tmp1 (NVector), tmp2 (NVector), and tmp3 (NVector) as parameters, and return an integer."""
if func == None:
return ctypes.cast(None, CVDenseJacFn)
exec 'def __CallbackInterface_%s(N, J, t, y, fy, jac_data, tmp1, tmp2, tmp3):\n\treturn __ActualCallback[%i](N, DenseMat(J), t, nvecserial.NVector(y), nvecserial.NVector(fy), jac_data, nvecserial.NVector(tmp1), nvecserial.NVector(tmp2), nvecserial.NVector(tmp3))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVDenseJacFn(eval("__CallbackInterface_%s"%(func.func_name)))
def WrapCallbackCVDenseJacFnB(func):
if func == None:
return ctypes.cast(None, CVDenseJacFnB)
exec 'def __CallbackInterface_%s(nB, JB, t, y, yB, fyB, jac_dataB, tmp1B, tmp2B, tmp3B):\n\treturn __ActualCallback[%i](nB, DenseMat(JB), t, nvecserial.NVector(y), nvecserial.NVector(yB), nvecserial.NVector(fyB), jac_dataB, nvecserial.NVector(tmp1B), nvecserial.NVector(tmp2B), nvecserial.NVector(tmp3B))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVDenseJacFnB(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
def WrapCallbackCVSpilsPrecSetupFn(func):
"""Creates a wrapper around a python callable object, that can be used as a callback for the preconditioner setup function."""
if func == None:
return ctypes.cast(None, CVSpilsPrecSetupFn)
exec 'def __CallbackInterface_%s(t, y, fy, jok, jcurPtr, gamma, P_data, tmp1, tmp2, tmp3):\n\treturn __ActualCallback[%i](t, nvecserial.NVector(y), nvecserial.NVector(fy), jok, jcurPtr, gamma, P_data, nvecserial.NVector(tmp1), nvecserial.NVector(tmp2), nvecserial.NVector(tmp3))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVSpilsPrecSetupFn(eval("__CallbackInterface_%s"%(func.func_name)))
def WrapCallbackCVSpilsPrecSolveFn(func):
"""Creates a wrapper around a python callable object, that can be used as a callback for the preconditioner solve function."""
if func == None:
return ctypes.cast(None, CVSpilsPrecSolveFn)
exec 'def __CallbackInterface_%s(t, y, fy, r, z, gamma, delta, lr, P_data, tmp):\n\treturn __ActualCallback[%i](t, nvecserial.NVector(y), nvecserial.NVector(fy), nvecserial.NVector(r), nvecserial.NVector(z), gamma, delta, lr, P_data, nvecserial.NVector(tmp))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVSpilsPrecSolveFn(eval("__CallbackInterface_%s"%(func.func_name)))
def WrapCallbackCVSpilsJacTimesVecFn(func):
"""Creates a wrapper around a python callable object, that can be used as a callback for the jtimes solve function."""
if func == None:
return ctypes.cast(None, CVSpilsJacTimesVecFn)
exec 'def __CallbackInterface_%s(v, Jv, t, y, fy, jac_data, tmp):\n\treturn __ActualCallback[%i](nvecserial.NVector(v), nvecserial.NVector(Jv), t, nvecserial.NVector(y), nvecserial.NVector(fy), jac_data, nvecserial.NVector(tmp))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVSpilsJacTimesVecFn(eval("__CallbackInterface_%s"%(func.func_name)))
def WrapCallbackCVSpilsPrecSetupFnB(func):
if func == None:
return ctypes.cast(None, CVSpilsPrecSetupFnB)
exec 'def __CallbackInterface_%s(t, y, yB, fyB, jokB, jcurPtrB, gammaB, P_dataB, tmp1B, tmp2B, tmp3B):\nreturn __ActualCallback[%i](t, nvecserial.NVector(y), nvecserial.NVector(yB), nvecserial.NVector(fyB), jokB, ctypes.byref(jcurPtrB), gammaB, P_dataB, nvecserial.NVector(tmp1B), nvecserial.NVector(tmp2B), nvecserial.NVector(tmp3B))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVSpilsPrecSetupFnB(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
return tmp
CVSpilsPrecSolveFnB = ctypes.CFUNCTYPE(ctypes.c_int, realtype, ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), realtype, realtype, ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(nvecserial._NVector))
def WrapCallbackCVSpilsPrecSolveFnB(func):
if func == None:
return ctypes.cast(None, CVSpilsPrecSolveFnB)
def WrapCallbackCVSpilsJacTimesVecFnB(func):
if func == None:
return ctypes.cast(None, CVSpilsJacTimesVecFnB)
exec 'def __CallbackInterface_%s(vB, JvB, t, y, yB, fyB, jac_dataB, tmpB):\nreturn __ActualCallback[%i](nvecserial.NVector(vB), nvecserial.NVector(JvB), t, nvecserial.NVector(y), nvecserial.NVector(yB), nvecserial.NVector(fyB), jac_dataB, nvecserial.NVector(tmpB))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVSpilsJacTimesVecFnB(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
src/p/y/pysces-HEAD/pysces_pysundials/pysundials/cvodes.py pysces(Download)
def WrapCallbackCVRhsFn(func):
"""Returns a callback wrapper around the given python callable object (func). This function should never be called directly, as it is called implicitly by any functions that specify a RHS function.\n\nThe callable python objet must takes exactly 4 parameters, which will be passed in as\n\ttime_step (float)\n\ty (NVector)\n\tydot (NVector)\n\tf_data (c_void_p)\n\nand must return an integer of 0 in the case of no error, otherwise a user defined integer indicating an error condition."""
if func == None:
return ctypes.cast(None, CVRhsFn)
exec 'def __CallbackInterface_%s(t, y, ydot, f_data):\n\treturn __ActualCallback[%i](t, nvecserial.NVector(y), nvecserial.NVector(ydot), f_data)'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVRhsFn(eval("__CallbackInterface_%s"%(func.func_name)))
def WrapCallbackCVRootFn(func):
"""Returns a callback wrapper around the given python callable object (func). This function should never be called directly, as it is called implicitly by any functions that specify a root finding function.\n\nThe callable python objet must takes exactly 4 parameters, which will be passed in as\n\ttime_step (float)\n\ty (NVector)\n\tgout (NVector)\n\tg_data (c_void_p)\n\nand must return an integer of 0 in the case of no error, otherwise a user defined integer indicating an error condition."""
if func == None:
return ctypes.cast(None, CVRootFn)
exec 'def __CallbackInterface_%s(t, y, gout, g_data):\n\treturn __ActualCallback[%i](t, nvecserial.NVector(y), gout, g_data)'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVRootFn(eval("__CallbackInterface_%s"%(func.func_name)))
def WrapCallbackCVEwtFn(func):
"""Returns a callback wrapper around the given python callable object (func). This function should never be called directly, as it is called implicitly by any functions that specify an error weight function.\n\nThe callable python objet must takes exactly 3 parameters, which will be passed in as\n\ty (NVector)\n\tewt (NVector)\n\te_data (c_void_p)\n\nand must return an integer of 0 in the case of no error, otherwise a user defined integer indicating an error condition."""
if func == None:
return ctypes.cast(None, CVEwtFn)
exec 'def __CallbackInterface_%s(y, ewt, e_data):\n\treturn __ActualCallback[%i](nvecserial.NVector(y), nvecserial.NVector(ewt), e_data)'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVEwtFn(eval("__CallbackInterface_%s"%(func.func_name)))
def WrapCallbackCVErrHandlerFn(func):
"""Creates a wrapper around a python callable object, that can be used as a callback for the error handler function. Error handler functions take error_code (int), module (string), function_name (string), message (string), and eh_data (c_void_p) as parameters, and have no return value."""
if func == None:
return ctypes.cast(None, CVErrHandlerFn)
exec 'def __CallbackInterface_%s(error_code, module, function, msg, eh_data):\n\treturn __ActualCallback[%i](error_code, module, function, msg, eh_data)'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVErrHandlerFn(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
return tmp
CVQuadRhsFn = ctypes.CFUNCTYPE(ctypes.c_int, realtype, ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.c_void_p)
def WrapCallbackCVQuadRhsFn(func):
if func == None:
return ctypes.cast(None, CVQuadRhsFn)
def WrapCallbackCVSensRhsFn(func):
if func == None:
return ctypes.cast(None, CVSensRhsFn)
exec 'def __CallbackInterface_%s(Ns, t, y, ydot, yS, ySdot, fS_data, tmp1, tmp2):\n\treturn __ActualCallback[%i](Ns, t, nvecserial.NVector(y), nvecserial.NVector(ydot), nvecserial.NVector(yS), nvecserial.NVector(ySdot), fS_data, nvecserial.NVector(tmp1), nvecserial.NVector(tmp2))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVSensRhsFn(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
return tmp
CVSensRhs1Fn = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int, realtype, ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.c_int, ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.c_void_p, ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector))
def WrapCallbackCVSensRhs1Fn(func):
if func == None:
return ctypes.cast(None, CVSensRhs1Fn)
def WrapCallbackCVRhsFnB(func):
if func == None:
return ctypes.cast(None, CVRhsFnB)
exec 'def __CallbackInterface_%s(t, y, yB, yBdot, f_dataB):\n\treturn __ActualCallback[%i](t, nvecserial.NVector(y), nvecserial.NVector(yB), nvecserial.NVector(yBdot), f_dataB)'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVRhsFnB(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
return tmp
CVQuadRhsFnB = ctypes.CFUNCTYPE(ctypes.c_int, realtype, ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.c_void_p)
def WrapCallbackCVQuadRhsFnB(func):
if func == None:
return ctypes.cast(None, CVQuadRhsFnB)
def WrapCallbackATimesFn(func):
if (func == None):
return ctypes.cast(None, ATimesFn)
exec 'def __CallbackInterface_%s(A_data, v, z):\n\treturn __ActualCallback[%i](A_data, nvecserial.NVector(v), nvecserial.NVector(z))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = ATimesFn(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
return tmp
PSolveFn = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.c_int)
def WrapCallbackPSolveFn(func):
if (func == None):
return ctypes.cast(None, PSolveFn)
def WrapCallbackCVLocalFn(func):
"""Creates a wrapper around a python callable object, that can be used as a callback for the local approximation RHS function. Local approximation RHS functions take Nlocal (int = size of local vector), time_step (float), y (NVector), g (NVector), and f_data (c_void_p) as parameters, and return an integer."""
if func == None:
return ctypes.cast(None, CVLocalFn)
exec 'def __CallbackInterface_%s(Nlocal, t, y, g, f_data):\n\treturn __ActualCallback[%i](Nlocal, t, nvecserial.NVector(y), nvecserial.NVector(g), f_data)'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVLocalFn(eval("__CallbackInterface_%s"%(func.func_name)))
def WrapCallbackCVCommFn(func):
"""Creates a wrapper around a python callable object, that can be used to perform all IPC necessary to approximate the RHS function. Such functions take Nlocal (int = size of local vector), time_step (float), y (NVector), and f_data (c_void_p) as parameters, and return nothing."""
if func == None:
return ctypes.cast(None, CVCommFn)
exec 'def __CallbackInterface_%s(Nlocal, t, y, f_data):\n\treturn __ActualCallback[%i](Nlocal, t, nvecserial.NVector(y), f_data)'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVCommFn(eval("__CallbackInterface_%s"%(func.func_name)))
def WrapCallbackCVLocalFnB(func):
exec 'def __CallbackInterface_%s(NlocalB, t, y, yB, gB, f_dataB):\n\treturn __ActualCallback[%i](NlocalB, t, nvecserial.NVector(y), nvecserial.NVector(yB), nvecserial.NVector(gB), f_dataB)'%(func.func_name, len(__ActualCallback))
if func == None:
return ctypes.cast(None, CVLocalFnB)
__ActualCallback.append(func)
tmp = CVLocalFnB(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
return tmp
CVCommFnB = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_long, realtype, ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.c_void_p)
def WrapCallbackCVCommFnB(func):
exec 'def __CallbackInterface_%s(NlocalB, t, y, yB, f_dataB):\n\treturn __ActualCallback[%i](NlocalB, t, nvecserial.NVector(y), nvecserial.NVector(yB), f_dataB)'%(func.func_name, len(__ActualCallback))
if func == None:
return ctypes.cast(None, CVCommFnB)
def WrapCallbackCVBandJacFn(func):
"""Creates a wrapper around a python callable object, that can be used as a callback for the Jacobian function. Jacobian functions for banded matrices take N (int = dimension of matrix), muppper (int = upper band width), mlower (int = lower band width), t (float = time step), J (BandMat = Jacobian Matrix), y (NVector), fy (NVector), jac_data (c_void_p), tmp1 (NVector), tmp2 (NVector), and tmp3 (NVector) as parameters, and return an integer."""
if func == None:
return ctypes.cast(None, CVBandJacFn)
exec 'def __CallbackInterface_%s(N, mupper, mlower, J, t, y, fy, jac_data, tmp1, tmp2, tmp3):\n\treturn __ActualCallback[%i](N, mupper, mlower, BandMat(J), t, nvecserial.NVector(y), nvecserial.NVector(fy), jac_data, nvecserial.NVector(tmp1), nvecserial.NVector(tmp2), nvecserial.NVector(tmp3))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVBandJacFn(eval("__CallbackInterface_%s"%(func.func_name)))
def WrapCallbackCVBandJacFnB(func):
exec 'def __CallbackInterface_%s(nB, mupperB, mlowerB, JB, t, y, yB, fyB, jac_dataB, tmp1B, tmp2B, tmp3B):\n\treturn __ActualCallback[%i](nB, mupperB, mlowerB, BandMat(JB), t, nvecserial.NVector(y), nvecserial.NVector(yB), nvecserial.NVector(fyB), jac_dataB, nvecserial.NVector(tmp1B), nvecserial.NVector(tmp2B), nvecserial.NVector(tmp3B))'%(func.func_name, len(__ActualCallback))
if func == None:
return ctypes.cast(None, CVBandJacFnB)
__ActualCallback.append(func)
tmp = CVBandJacFnB(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
def WrapCallbackCVDenseJacFn(func):
"""Creates a wrapper around a python callable object, that can be used as a callback for the Jacobian function. Jacobian functions for dense matrices take N (int = dimension of matrix), J (DenseMat = Jacobian Matrix), t (float = time step), y (NVector), fy (NVector), jac_data (c_void_p), tmp1 (NVector), tmp2 (NVector), and tmp3 (NVector) as parameters, and return an integer."""
if func == None:
return ctypes.cast(None, CVDenseJacFn)
exec 'def __CallbackInterface_%s(N, J, t, y, fy, jac_data, tmp1, tmp2, tmp3):\n\treturn __ActualCallback[%i](N, DenseMat(J), t, nvecserial.NVector(y), nvecserial.NVector(fy), jac_data, nvecserial.NVector(tmp1), nvecserial.NVector(tmp2), nvecserial.NVector(tmp3))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVDenseJacFn(eval("__CallbackInterface_%s"%(func.func_name)))
def WrapCallbackCVDenseJacFnB(func):
if func == None:
return ctypes.cast(None, CVDenseJacFnB)
exec 'def __CallbackInterface_%s(nB, JB, t, y, yB, fyB, jac_dataB, tmp1B, tmp2B, tmp3B):\n\treturn __ActualCallback[%i](nB, DenseMat(JB), t, nvecserial.NVector(y), nvecserial.NVector(yB), nvecserial.NVector(fyB), jac_dataB, nvecserial.NVector(tmp1B), nvecserial.NVector(tmp2B), nvecserial.NVector(tmp3B))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVDenseJacFnB(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
def WrapCallbackCVSpilsPrecSetupFn(func):
"""Creates a wrapper around a python callable object, that can be used as a callback for the preconditioner setup function."""
if func == None:
return ctypes.cast(None, CVSpilsPrecSetupFn)
exec 'def __CallbackInterface_%s(t, y, fy, jok, jcurPtr, gamma, P_data, tmp1, tmp2, tmp3):\n\treturn __ActualCallback[%i](t, nvecserial.NVector(y), nvecserial.NVector(fy), jok, jcurPtr, gamma, P_data, nvecserial.NVector(tmp1), nvecserial.NVector(tmp2), nvecserial.NVector(tmp3))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVSpilsPrecSetupFn(eval("__CallbackInterface_%s"%(func.func_name)))
def WrapCallbackCVSpilsPrecSolveFn(func):
"""Creates a wrapper around a python callable object, that can be used as a callback for the preconditioner solve function."""
if func == None:
return ctypes.cast(None, CVSpilsPrecSolveFn)
exec 'def __CallbackInterface_%s(t, y, fy, r, z, gamma, delta, lr, P_data, tmp):\n\treturn __ActualCallback[%i](t, nvecserial.NVector(y), nvecserial.NVector(fy), nvecserial.NVector(r), nvecserial.NVector(z), gamma, delta, lr, P_data, nvecserial.NVector(tmp))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVSpilsPrecSolveFn(eval("__CallbackInterface_%s"%(func.func_name)))
def WrapCallbackCVSpilsJacTimesVecFn(func):
"""Creates a wrapper around a python callable object, that can be used as a callback for the jtimes solve function."""
if func == None:
return ctypes.cast(None, CVSpilsJacTimesVecFn)
exec 'def __CallbackInterface_%s(v, Jv, t, y, fy, jac_data, tmp):\n\treturn __ActualCallback[%i](nvecserial.NVector(v), nvecserial.NVector(Jv), t, nvecserial.NVector(y), nvecserial.NVector(fy), jac_data, nvecserial.NVector(tmp))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVSpilsJacTimesVecFn(eval("__CallbackInterface_%s"%(func.func_name)))
def WrapCallbackCVSpilsPrecSetupFnB(func):
if func == None:
return ctypes.cast(None, CVSpilsPrecSetupFnB)
exec 'def __CallbackInterface_%s(t, y, yB, fyB, jokB, jcurPtrB, gammaB, P_dataB, tmp1B, tmp2B, tmp3B):\nreturn __ActualCallback[%i](t, nvecserial.NVector(y), nvecserial.NVector(yB), nvecserial.NVector(fyB), jokB, ctypes.byref(jcurPtrB), gammaB, P_dataB, nvecserial.NVector(tmp1B), nvecserial.NVector(tmp2B), nvecserial.NVector(tmp3B))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVSpilsPrecSetupFnB(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
return tmp
CVSpilsPrecSolveFnB = ctypes.CFUNCTYPE(ctypes.c_int, realtype, ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), realtype, realtype, ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(nvecserial._NVector))
def WrapCallbackCVSpilsPrecSolveFnB(func):
if func == None:
return ctypes.cast(None, CVSpilsPrecSolveFnB)
def WrapCallbackCVSpilsJacTimesVecFnB(func):
if func == None:
return ctypes.cast(None, CVSpilsJacTimesVecFnB)
exec 'def __CallbackInterface_%s(vB, JvB, t, y, yB, fyB, jac_dataB, tmpB):\nreturn __ActualCallback[%i](nvecserial.NVector(vB), nvecserial.NVector(JvB), t, nvecserial.NVector(y), nvecserial.NVector(yB), nvecserial.NVector(fyB), jac_dataB, nvecserial.NVector(tmpB))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = CVSpilsJacTimesVecFnB(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
src/p/y/pysces-HEAD/trunk/pysces_pysundials/pysundials/ida.py pysces(Download)
def WrapCallbackIDAResFn(func):
if func == None:
return ctypes.cast(None, IDAResFn)
exec 'def __CallbackInterface_%s(tt, yy, yp, rr, res_data):\n\treturn __ActualCallback[%i](tt, nvecserial.NVector(yy), nvecserial.NVector(yp), nvecserial.NVector(rr), res_data)'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = IDAResFn(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
return tmp
IDARootFn = ctypes.CFUNCTYPE(ctypes.c_int, realtype, ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(realtype ), ctypes.c_void_p)
def WrapCallbackIDARootFn(func):
if func == None:
return ctypes.cast(None, IDARootFn)
def WrapCallbackIDAEwtFn(func):
if func == None:
return ctypes.cast(None, IDAEwtFn)
exec 'def __CallbackInterface_%s(y, ewt, e_data):\n\treturn __ActualCallback[%i](nvecserial.NVector(y), nvecserial.NVector(ewt), e_data)'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = IDAEwtFn(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
return tmp
IDAErrHandlerFn = ctypes.CFUNCTYPE(None, ctypes.c_int, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_void_p)
def WrapCallbackIDAErrHandlerFn(func):
if func == None:
return ctypes.cast(None, IDAErrHandlerFn)
def WrapCallbackATimesFn(func):
if (func == None):
return ctypes.cast(None, ATimesFn)
exec 'def __CallbackInterface_%s(A_data, v, z):\n\treturn __ActualCallback[%i](A_data, nvecserial.NVector(v), nvecserial.NVector(z))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = ATimesFn(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
return tmp
PSolveFn = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.c_int)
def WrapCallbackPSolveFn(func):
if (func == None):
return ctypes.cast(None, PSolveFn)
def WrapCallbackIDABandJacFn(func):
if func == None:
return ctypes.cast(None, IDABandJacFn)
exec 'def __CallbackInterface_%s(Neq, mupper, mlower, tt, yy, yp, rr, c_j, jac_data, Jac, tmp1, tmp2, tmp3):\n\treturn __ActualCallback[%i](Neq, mupper, mlower, tt, nvecserial.NVector(yy), nvecserial.NVector(yp), nvecserial.NVector(rr), c_j, jac_data, BandMat(Jac), nvecserial.NVector(tmp1), nvecserial.NVector(tmp2), nvecserial.NVector(tmp3))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = IDABandJacFn(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
def WrapCallbackIDABBDLocalFn(func):
if func == None:
return ctypes.cast(None, IDABBDLocalFn)
exec 'def __CallbackInterface_%s(Nlocal, tt, yy, yp, gval, res_data):\n\treturn __ActualCallback[%i](Nlocal, tt, nvecserial.NVector(yy), nvecserial.NVector(yp), nvecserial.NVector(gval), res_data)'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = IDABBDLocalFn(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
return tmp
IDABBDCommFn = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_long, realtype, ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.c_void_p)
def WrapCallbackIDABBDCommFn(func):
if func == None:
return ctypes.cast(None, IDABBDCommFn)
def WrapCallbackIDADenseJacFn(func):
if func == None:
return ctypes.cast(None, IDADenseJacFn)
exec 'def __CallbackInterface_%s(Neq, tt, yy, yp, rr, c_j, jac_data, Jac, tmp1, tmp2, tmp3):\n\treturn __ActualCallback[%i](Neq, tt, nvecserial.NVector(yy), nvecserial.NVector(yp), nvecserial.NVector(rr), c_j, jac_data, DenseMat(Jac), nvecserial.NVector(tmp1), nvecserial.NVector(tmp2), nvecserial.NVector(tmp3))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = IDADenseJacFn(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
def WrapCallbackIDASpilsPrecSetupFn(func):
if func == None:
return ctypes.cast(None, IDASpilsPrecSetupFn)
exec 'def __CallbackInterface_%s(tt, yy, yp, rr, c_j, prec_data, tmp1, tmp2, tmp3):\n\treturn __ActualCallback[%i](tt, nvecserial.NVector(yy), nvecserial.NVector(yp), nvecserial.NVector(rr), c_j, prec_data, nvecserial.NVector(tmp1), nvecserial.NVector(tmp2), nvecserial.NVector(tmp3))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = IDASpilsPrecSetupFn(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
return tmp
IDASpilsPrecSolveFn = ctypes.CFUNCTYPE(ctypes.c_int, realtype, ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), realtype, realtype, ctypes.c_void_p, ctypes.POINTER(nvecserial._NVector))
def WrapCallbackIDASpilsPrecSolveFn(func):
if func == None:
return ctypes.cast(None, IDASpilsPrecSolveFn)
def WrapCallbackIDASpilsJacTimesVecFn(func):
if func == None:
return ctypes.cast(None, IDASpilsJacTimesVecFn)
exec 'def __CallbackInterface_%s(tt, yy, yp, rr, v, Jv, c_j, jac_data, tmp1, tmp2):\n\treturn __ActualCallback[%i](tt, nvecserial.NVector(yy), nvecserial.NVector(yp), nvecserial.NVector(rr), nvecserial.NVector(v), nvecserial.NVector(Jv), c_j, jac_data, nvecserial.NVector(tmp1), nvecserial.NVector(tmp2))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = IDASpilsJacTimesVecFn(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
src/p/y/pysces-HEAD/pysces_pysundials/pysundials/ida.py pysces(Download)
def WrapCallbackIDAResFn(func):
if func == None:
return ctypes.cast(None, IDAResFn)
exec 'def __CallbackInterface_%s(tt, yy, yp, rr, res_data):\n\treturn __ActualCallback[%i](tt, nvecserial.NVector(yy), nvecserial.NVector(yp), nvecserial.NVector(rr), res_data)'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = IDAResFn(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
return tmp
IDARootFn = ctypes.CFUNCTYPE(ctypes.c_int, realtype, ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(realtype ), ctypes.c_void_p)
def WrapCallbackIDARootFn(func):
if func == None:
return ctypes.cast(None, IDARootFn)
def WrapCallbackIDAEwtFn(func):
if func == None:
return ctypes.cast(None, IDAEwtFn)
exec 'def __CallbackInterface_%s(y, ewt, e_data):\n\treturn __ActualCallback[%i](nvecserial.NVector(y), nvecserial.NVector(ewt), e_data)'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = IDAEwtFn(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
return tmp
IDAErrHandlerFn = ctypes.CFUNCTYPE(None, ctypes.c_int, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_void_p)
def WrapCallbackIDAErrHandlerFn(func):
if func == None:
return ctypes.cast(None, IDAErrHandlerFn)
def WrapCallbackATimesFn(func):
if (func == None):
return ctypes.cast(None, ATimesFn)
exec 'def __CallbackInterface_%s(A_data, v, z):\n\treturn __ActualCallback[%i](A_data, nvecserial.NVector(v), nvecserial.NVector(z))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = ATimesFn(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
return tmp
PSolveFn = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.c_int)
def WrapCallbackPSolveFn(func):
if (func == None):
return ctypes.cast(None, PSolveFn)
def WrapCallbackIDABandJacFn(func):
if func == None:
return ctypes.cast(None, IDABandJacFn)
exec 'def __CallbackInterface_%s(Neq, mupper, mlower, tt, yy, yp, rr, c_j, jac_data, Jac, tmp1, tmp2, tmp3):\n\treturn __ActualCallback[%i](Neq, mupper, mlower, tt, nvecserial.NVector(yy), nvecserial.NVector(yp), nvecserial.NVector(rr), c_j, jac_data, BandMat(Jac), nvecserial.NVector(tmp1), nvecserial.NVector(tmp2), nvecserial.NVector(tmp3))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = IDABandJacFn(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
def WrapCallbackIDABBDLocalFn(func):
if func == None:
return ctypes.cast(None, IDABBDLocalFn)
exec 'def __CallbackInterface_%s(Nlocal, tt, yy, yp, gval, res_data):\n\treturn __ActualCallback[%i](Nlocal, tt, nvecserial.NVector(yy), nvecserial.NVector(yp), nvecserial.NVector(gval), res_data)'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = IDABBDLocalFn(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
return tmp
IDABBDCommFn = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_long, realtype, ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.c_void_p)
def WrapCallbackIDABBDCommFn(func):
if func == None:
return ctypes.cast(None, IDABBDCommFn)
def WrapCallbackIDADenseJacFn(func):
if func == None:
return ctypes.cast(None, IDADenseJacFn)
exec 'def __CallbackInterface_%s(Neq, tt, yy, yp, rr, c_j, jac_data, Jac, tmp1, tmp2, tmp3):\n\treturn __ActualCallback[%i](Neq, tt, nvecserial.NVector(yy), nvecserial.NVector(yp), nvecserial.NVector(rr), c_j, jac_data, DenseMat(Jac), nvecserial.NVector(tmp1), nvecserial.NVector(tmp2), nvecserial.NVector(tmp3))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = IDADenseJacFn(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
def WrapCallbackIDASpilsPrecSetupFn(func):
if func == None:
return ctypes.cast(None, IDASpilsPrecSetupFn)
exec 'def __CallbackInterface_%s(tt, yy, yp, rr, c_j, prec_data, tmp1, tmp2, tmp3):\n\treturn __ActualCallback[%i](tt, nvecserial.NVector(yy), nvecserial.NVector(yp), nvecserial.NVector(rr), c_j, prec_data, nvecserial.NVector(tmp1), nvecserial.NVector(tmp2), nvecserial.NVector(tmp3))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = IDASpilsPrecSetupFn(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
return tmp
IDASpilsPrecSolveFn = ctypes.CFUNCTYPE(ctypes.c_int, realtype, ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), ctypes.POINTER(nvecserial._NVector), realtype, realtype, ctypes.c_void_p, ctypes.POINTER(nvecserial._NVector))
def WrapCallbackIDASpilsPrecSolveFn(func):
if func == None:
return ctypes.cast(None, IDASpilsPrecSolveFn)
def WrapCallbackIDASpilsJacTimesVecFn(func):
if func == None:
return ctypes.cast(None, IDASpilsJacTimesVecFn)
exec 'def __CallbackInterface_%s(tt, yy, yp, rr, v, Jv, c_j, jac_data, tmp1, tmp2):\n\treturn __ActualCallback[%i](tt, nvecserial.NVector(yy), nvecserial.NVector(yp), nvecserial.NVector(rr), nvecserial.NVector(v), nvecserial.NVector(Jv), c_j, jac_data, nvecserial.NVector(tmp1), nvecserial.NVector(tmp2))'%(func.func_name, len(__ActualCallback))
__ActualCallback.append(func)
tmp = IDASpilsJacTimesVecFn(eval("__CallbackInterface_%s"%(func.func_name)))
__Callback.append(tmp)
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next