小编klu*_*bow的帖子

将2维C数组传递给python numpy

关于将C数组传递给python(numpy)我需要一些帮助.我有2d数组的双倍NumRows x NumInputs,它似乎PyArray_SimpleNewFromData没有正确的方式转换 - 很难看到因为调试器没有显示太多,只有指针.

传递二维数组的正确方法是什么?

int NumRows = X_test.size();
int NumInputs = X_test_row.size();

double **X_test2 = new double*[NumRows];
for(int i = 0; i < NumRows; ++i) 
{
    X_test2[i] = new double[NumInputs];
}


for(int r = 0; r < NumRows; ++r) 
{
    for(int c = 0; c < NumInputs; ++c) 
    {
        X_test2[r][c] = X_test[r][c];
    }
}




const char *ScriptFName = "100-ABN-PREDICT";
char *FunctionName=NULL;

FunctionName="PredictGBC_DBG"; 

npy_intp Dims[2];
Dims[0]= NumRows;
Dims[1] = NumInputs;

PyObject *ArgsArray;
PyObject *pName, *pModule, *pDict, *pFunc, …
Run Code Online (Sandbox Code Playgroud)

c++ python arrays numpy

5
推荐指数
1
解决办法
2691
查看次数

标签 统计

arrays ×1

c++ ×1

numpy ×1

python ×1