Pybind11:可用的 array_t 构造函数
我想从 double* 和 size 创建一个 array_t 。
我没有找到文档中明确提到的构造函数。
我尝试复制此线程: PyBind11:将 c++ 数组返回为 numpy数组更改值
但是当我尝试时,出现错误: 致命错误:没有匹配的构造函数来初始化“py::array_t” py::array_t 测试 = py::array_t({size, DIM},{DIM*8, 8}, 数据);
其中 size 和 dim 是 unsigned int,data 是 double*。
我如何构造一个 array_t,更重要的是,这些信息在哪里可用?
I want to create an array_t from a double* and size.
I did not find a constructor mentioned explicitely in the docs.
I tried to copy this thread : PyBind11 : returning c++ array as numpy array changes values
But when I try, I get an error :
fatal error: no matching constructor for initialization of 'py::array_t'
py::array_t test = py::array_t({size, DIM},{DIM*8, 8}, data);
where size and dim are unsigned int and data is a double*.
How can I construct an array_t, and, more importantly, where is this information available ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在某些情况下,我很幸运,编译器告诉我哪些构造函数可用。
这里的解决方案是确保形状和步幅正确:
In some cases I got lucky and the compiler told me which constructors were available.
The solution here was to make sure that the shape and stride were correct :