Python 更改pybind11中参数数组中的值
我有以下小型Python 更改pybind11中参数数组中的值,python,numpy,eigen,pybind11,Python,Numpy,Eigen,Pybind11,我有以下小型pybind11代码: void f( Eigen::MatrixXd& vertices ){ vertices(0, 0) = 55.0; } PYBIND11_MODULE(test, m) { m.def("f", &f, ""); } 以及相应的Python: v = np.array([[1, 2], [1, 2]]) f(v) print(v) 基本上,我创建了一个Numpy数组,Python绑定应该将55写入其中一个数组单
pybind11
代码:
void f(
Eigen::MatrixXd& vertices
){
vertices(0, 0) = 55.0;
}
PYBIND11_MODULE(test, m) {
m.def("f", &f, "");
}
以及相应的Python:
v = np.array([[1, 2], [1, 2]])
f(v)
print(v)
基本上,我创建了一个Numpy数组,Python绑定应该将55写入其中一个数组单元格
不幸的是,当打印v
时,它似乎没有写入55
<强>我如何实现C++代码中数组的更改在Python代码中也起作用?< /强>