1
Numpy配列をC++コードにプッシュしようとしています。Numpy NDPointer:パラメータ1の変換方法がわからない
C++関数は、
extern "C"
void propagate(float * __restrict__ H, const float * __restrict__ W,
const float * __restrict__ U, const float * __restrict__ x,
float a, int h_len, int samples);
私のPythonコードは、私が
Traceback (most recent call last):
File "./minimal.py", line 23, in <module>
propagate(H, W, U, X, a, U.shape[0], X.shape[0])
ctypes.ArgumentError: argument 1: <type 'exceptions.TypeError'>: Don't know how to convert parameter 1
は、私はこれをどのように修正すればよい、エラーを取得し、
from numpy import *
from numpy.ctypeslib import ndpointer
import ctypes
lib = ctypes.cdll.LoadLibrary("libesn.so")
propagate = lib.propagate
propagate.restype = None
propagate.argtype = [ndpointer(ctypes.c_float, flags="C_CONTIGUOUS"),
ndpointer(ctypes.c_float, flags="C_CONTIGUOUS"),
ndpointer(ctypes.c_float, flags="C_CONTIGUOUS"),
ndpointer(ctypes.c_float, flags="C_CONTIGUOUS"),
ctypes.c_float, ctypes.c_int, ctypes.c_int]
H = W = U = X = zeros((10, 10))
a = 5.0
propagate(H, W, U, X, a, U.shape[0], X.shape[0])
ですか?