1
Numpy 배열을 C++ 코드로 푸시하려고합니다.Numpy NDPointer : 매개 변수 1을 변환하는 방법을 모릅니다.
는 C++ 기능은 내가 오류 얻을
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])
,
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
가 어떻게이 문제를 해결 않습니다
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);
내 파이썬 코드가있다?