我在 dll 文件中有一个函数,它将浮点指针作为参数之一(参数 9:float *result)。
void generate_codebook(int *nodestatus, int *nofnode, int *noftree, int *terminal, int *nofterminal, int *nofobservations, int *total, int *nofseries, float *result)
这是我遇到问题的python代码:
nofseries=c_int(len(nofobservations))
noftree=c_int(terminal.shape[1])
nofnode=c_int(nodestatus.shape[0])
total=c_int(np.sum(nofobservations,dtype=np.int64))
nofentry=ctypes.POINTER(ctypes.c_float *(len(nofobservations)*nofterminal*terminal.shape[1]))()
mydll.generate_codebook.argtypes = [POINTER(c_int), POINTER(c_int), POINTER(c_int), POINTER(c_int),
POINTER(c_int), POINTER(c_int), POINTER(c_int), POINTER(c_int), POINTER(c_float)]
result=mydll.generate_codebook(nodestatus.ctypes.data_as(ctypes.POINTER(ctypes.c_int)),
nofnode,noftree,terminal.ctypes.data_as(ctypes.POINTER(ctypes.c_int)),
c_int(nofterminal),
nofobservations.ctypes.data_as(ctypes.POINTER(ctypes.c_int)),total,
nofseries,
ctypes.byref(nofentry))
在调用 generate_codebook 函数时,我在需要 LP_c_float 实例的最后一个参数中遇到参数错误。下面是错误:
<ipython-input-28-f73a7383211e> in generatecodebook(nodestatus, terminal, nofterminal, nofobservations)
16 nofobservations.ctypes.data_as(ctypes.POINTER(ctypes.c_int)),total,
17 nofseries,
---> 18 ctypes.byref(nofentry))
ArgumentError: argument 9: <class 'TypeError'>: expected LP_c_float instance instead of pointer to LP_c_float_Array_50000
我经历了这个问题的解决方案,但无法解决错误。先感谢您!
Qyouu
相关分类