我们可以创建一个特征矩阵的向量吗

Can we create a vector of Eigen Matrix?

本文关键字:特征 向量 一个 创建 我们      更新时间:2023-10-16

是否可以创建特征矩阵的向量?

例如,我运行以下行,

vector<Matrix<double,4,1>> vector_of_matrix;

但我收到以下错误,

error: template argument 3 is invalid
error: template argument 4 is invalid
error: template argument 6 is invalid
error: template argument 1 is invalid

有人想告诉我如何正确初始化特征矩阵的向量吗?注意,我已经考虑了特征动态大小矩阵作为一种替代方案,但我不希望这样。

根据文档,您必须

#include <Eigen/StdVector>

并使用

std::vector<Matrix<double,4,1>, Eigen::aligned_allocator<Matrix<double,4,1> > >

在指定模板结构时始终使用空格。否则c++将无法解析它。

vector<Matrix<double,4,1> > vector_of_matrix;

需要#include所需的头<Eigen/Core>和(C++标准)<vector>

根据编译器的使用年限,有必要在大于和小于符号之间留有空格(例如> >而不是>>,以避免编译器混淆)。较旧的标准要求这样做。