【问题标题】:How to Use Eigen with Pybind11如何在 Pybind11 中使用 Eigen
【发布时间】:2019-08-29 16:01:29
【问题描述】:

问题描述

我有一个简单的函数

void test2(Eigen::Matrix4f& mat){
    std::cout << mat << std::endl;
}

在我的 Python 代码中,我这样做了

pylc.test2(np.ones((4,4), dtype=np.float32))

但它崩溃了

TypeError: test2(): incompatible function arguments. The following argument types are supported:
    1. (arg0: Eigen::Matrix<float, 4, 4, 0, 4, 4>) -> None

Invoked with: array([[1., 1., 1., 1.],
       [1., 1., 1., 1.],
       [1., 1., 1., 1.],
       [1., 1., 1., 1.]], dtype=float32)

我做错了什么

【问题讨论】:

  • 为什么我会被否决?我在任何地方都找不到这个答案

标签: c++ eigen3 pybind11


【解决方案1】:

include &lt;pybind11/eigen.h&gt;

我忘了放这个..

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-14
    • 2018-04-28
    相关资源
    最近更新 更多