我想在C扩展中使用我的Numpy数组.
在这种情况下,许多示例使用PyArrayObject的结构,
array-> data,array-> strides [0],array-> strides [1],…
如果我想以更熟悉(或更整洁)的方式到达我的数组,以及像
阵列[i] [j]
我该怎么办呢?我应该转换(bool *)array->数据并使用我创建的C数组吗? (我的元素是bools)
我现在的功能声明是(当然没有完成)
static PyObject *
xor_masking(PyObject *self, PyObject *args)
{
PyObject *input;
PyObject *mask;
PyObject *adjacency;
PyObject *state;
PyArrayObject *arr_mask;
PyArrayObject *arr_adjacency;
PyArrayObject *arr_state;
PyArrayObject *arr_next_state;
double sum;
int counter_node, n_nodes;
/* PyArg_ParseTuple
* checks if from args, the pointers of type "O" can be extracted, and extracts them
*/
if (!PyArg_ParseTuple(args, "OOO:xor_masking_C", &mask, &adjacency, &state))
return NULL;
/*
* The pointer returned b