如何将特征与 Pybind11 一起使用

How to Use Eigen with Pybind11

本文关键字:一起 Pybind11 特征      更新时间:2023-10-16

问题描述

我有一个简单的功能,这样

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)

我做错了什么

include <pybind11/eigen.h>

我忘了放这个..