c++ - 编译时 Eigen 断言错误,不清楚的错误

标签 c++ eigen

所以我试图创建一个类,它基本上充当用于分区的特征矩阵的接口(interface),以及一些附加功能。我的数据结构的基本拷贝是:

template <class T>
class DataFile {
public:
    typedef Eigen::Matrix<DataType, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> RMatrix;
    DataFile(int inputRows, int inputColumns) {
        dataMatrix = RMatrix::Zero(inputRows, inputColumns);
    }
    inline typename RMatrix::RowXpr getSample(const int row) { return dataMatrix.row(row) }

private:
    RMatrix dataMatrix;

这只是对我所做的事情以及似乎相关的内容的简单介绍。当我使用 Qtcreator 和 MSVC2008 编译代码时,收到以下错误消息:

c:\apis_x64\eigen-eigen-ca142d0540d3\eigen\src/Core/DenseCoeffsBase.h(390) : error C2039: 'THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD' : is not a member of 'Eigen::internal::static_assertion<condition>'
        with
        [
            condition=false
        ]
        c:\apis_x64\eigen-eigen-ca142d0540d3\eigen\src/Core/DenseCoeffsBase.h(388) : while compiling class template member function 'float &Eigen::DenseCoeffsBase<Derived,Level>::operator [](__int64)'
        with
        [
            Derived=Eigen::Matrix<float,-1,-1,1>,
            Level=1
        ]
        c:\apis_x64\eigen-eigen-ca142d0540d3\eigen\src/Core/DenseCoeffsBase.h(653) : see reference to class template instantiation 'Eigen::DenseCoeffsBase<Derived,Level>' being compiled
        with
        [
            Derived=Eigen::Matrix<float,-1,-1,1>,
            Level=1
        ]
        c:\apis_x64\eigen-eigen-ca142d0540d3\eigen\src/Core/util/XprHelper.h(365) : see reference to class template instantiation 'Eigen::DenseCoeffsBase<Derived>' being compiled
        with
        [
            Derived=Eigen::Matrix<float,-1,-1,1>
        ]
        c:\apis_x64\eigen-eigen-ca142d0540d3\eigen\src/Core/DenseBase.h(53) : see reference to class template instantiation 'Eigen::internal::special_scalar_op_base<Derived,Scalar,OtherScalar>' being compiled
        with
        [
            Derived=Eigen::Matrix<float,-1,-1,1>,
            Scalar=float,
            OtherScalar=float
        ]
        c:\apis_x64\eigen-eigen-ca142d0540d3\eigen\src/Core/MatrixBase.h(65) : see reference to class template instantiation 'Eigen::DenseBase<Derived>' being compiled
        with
        [
            Derived=Eigen::Matrix<float,-1,-1,1>
        ]
        c:\apis_x64\eigen-eigen-ca142d0540d3\eigen\src/Core/PlainObjectBase.h(89) : see reference to class template instantiation 'Eigen::MatrixBase<Derived>' being compiled
        with
        [
            Derived=Eigen::Matrix<float,-1,-1,1>
        ]
        c:\apis_x64\eigen-eigen-ca142d0540d3\eigen\src/Core/Matrix.h(144) : see reference to class template instantiation 'Eigen::PlainObjectBase<Derived>' being compiled
        with
        [
            Derived=Eigen::Matrix<float,-1,-1,1>
        ]
        d:\users\public\documents\myCode\DataFilesV2.h(46) : see reference to class template instantiation 'Eigen::Matrix<_Scalar,_Rows,_Cols,_Options>' being compiled
        with
        [
            _Scalar=float,
            _Rows=-1,
            _Cols=-1,
            _Options=1
        ]
c:\apis_x64\eigen-eigen-ca142d0540d3\eigen\src/Core/DenseCoeffsBase.h(390) : error C2065: 'THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD' : undeclared identifier

d:\users\public\documents\myCode\DataFilesV2.h(46) 引用行 inline typename RMatrix::RowXpr getSample(const int row) { return dataMatrix.row(row) } 在我的代码中。我之前已经能够在代码的其他部分中完成这项工作,所以我的想法是它是在调用它。但是,在我调用此方法的所有时间中,都没有使用 [] 或 RowXpr 使用不当。 我有很多代码需要执行,所以我不太确定如何找到此错误,并可以使用一些想法来了解可能出现的问题或如何找出导致错误的原因。

最佳答案

我最终发现了错误,这就是 Eigen 所说的错误。我有一个从数组转换为特征矩阵的剩余 [] 。但问题与错误所指向的位置没有任何关系。我必须检查并注释掉错误所指向的位置,直到最终错误消失,并且我可以推断出代码的哪一部分是错误的真正来源。

关于c++ - 编译时 Eigen 断言错误,不清楚的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17538559/

相关文章:

c++ - Eigen - 将 vector reshape 为矩阵

c++ - 两个矩阵的C++高效按元素匹配

c++ - Boost Spirit Qi 语法用于合成关联二元运算符 AST 节点?

C++ 经常更改结构列表 - 只保留指针或整个结构?

c++ - Qt OSX全屏窗口上层菜单栏和Dock

c++ - 将 const uint16 arr[] 转换为 uint16 arr[]

c++ - OpenCV 3.1 + tesseract 3.04 的 OCR(文本识别)结果因识别顺序而异

c++ - 模板元编程 Eigen 表达式

c++ - 性能:Matlab 与 C++ 矩阵 vector 乘法

linear-regression - 权重变化时有效重新计算加权最小二乘回归