Проблема с PyArray_SimpleNewFromData - неизвестное местоположение? - PullRequest
0 голосов
/ 04 декабря 2018

Я пытаюсь вызвать некоторую функциональность np из cpp.Я создал массив, и я пытаюсь создать pyArray:

const int SIZE_X = 1000;
const int SIZE_Y = 9;
npy_intp dims[2]{SIZE_X, SIZE_Y};
const int ND = 2;
double* c_arr = reinterpret_cast<double*>(calloc(SIZE_X*SIZE_Y,sizeof(double)));
if (!c_arr) {
    std::cout << "Out of memory." << std::endl;
}
for (int i = 0; i < SIZE_X; i++)
  for (int j = 0; j < SIZE_Y; j++)
     c_arr[i*SIZE_Y+j] = something;

//Convert it to a NumPy array.
PyObject *pArray = PyArray_SimpleNewFromData(
    ND, dims, NPY_DOUBLE, reinterpret_cast<void*>(c_arr));

Я также пытался использовать новый.Я получаю ошибку:

unknown location:0: fatal error: in "basic": memory access violation at address: 0x00000010: no mapping at fault address

Я пробовал некоторые вещи, такие как import_array (), но это не помогло.Я не вижу, что мне не хватает?

...