将数据从 std::Vector 存储到 Eigen::Vector 时出错

Error storing data from std::Vector to Eigen::Vector

*error: no matching function for call to object of type 'Eigen::VectorXd' (aka 'Matrix<double, Dynamic, 1>')
DenseCoeffsBase.h:362:5: note: candidate function not viable: no known conversion from 'double *' to 'Eigen::Index' (aka 'long long') for 1st argument; dereference the argument with *
DenseCoeffsBase.h:115:41: note: candidate function not viable: no known conversion from 'double *' to 'Eigen::Index' (aka 'long long') for 1st argument; dereference the argument with *
DenseCoeffsBase.h:178:5: note: candidate function not viable: requires single argument 'index', but 2 arguments were provided
DenseCoeffsBase.h:423:5: note: candidate function not viable: requires single argument 'index', but 2 arguments were provided*

以上是我尝试将数据从标准向量存储到特征向量时出现的错误信息

这就是我正在尝试做的事情。我在通过这些命令返回的其他文件中制作了 std 向量,然后必须将它们转换为本征样式向量以与其他一些 code.I 集成已经尝试寻找将 std 向量数据存储到本征和我在另一个堆栈溢出 post 上发现了这种特殊方式。我不明白错误消息的含义。有人可以告诉我我做错了什么吗?

同样为了打印数据,我得到了这个错误 "Reference to non static member function must be called:did you mean to call it with no arguments"

我以为我通过调整大小使其成为静态矢量。

非常感谢您的帮助,并将添加任何必要的信息。我是 C++ 的新手,希望能有一些更简单的解释,因为我并不精通所有基础知识。

    simulator.h

    Eigen::VectorXd currentStartMassVector_, currentEndMassVector_ ,specificImpulses_   ;
    std::vector<double>       StartMassVector_, endMassVector_ , SpecificImpulseVector_  ;

    simulator.cpp

    currentStartMassVector_.resize(numberOfStages_);
    currentEndMassVector_.resize(numberOfStages_);
    specificImpulses_.resize(numberOfStages_);

    StartMassVector_            = launchVehicle->getMassStartStages();
    endMassVector_              = launchVehicle->getMassEndStages();
    SpecificImpulseVector_      = launchVehicle->getCurrentSpecificImpulse();

    currentStartMassVector_(StartMassVector_.data(),StartMassVector_.size())  ;
    currentEndMassVector_(endMassVector_.data(),endMassVector_.size()) ;
    specificImpulses_(SpecificImpulseVector_.data(),SpecificImpulseVector_.size());

        std::cout << "start mass vector" <<  currentStartMassVector_.transpose << std::endl;
        std::cout << "end mass vector"   <<  currentEndMassVector_.transpose << std::endl;
        std::cout << "Isp vector" <<  specificImpulses_.transpose << std::endl;

您只能使用构造函数来初始化之前未声明的向量。 在这种情况下,特征向量已在头文件中声明。

Eigen::Map() 可用于将数据从 std::vector<double> 复制到 Eigen::VectorXd,如下所示:

currentStartMassVector_ = Eigen::Map<Eigen::VectorXd>(StartMassVector_.data(),StartMassVector_.size()) ;