相关疑难解决方法(0)

正确使用Eigen :: Ref <>类

当不需要编写模板函数时,Eigen引入了Ref <>类来编写具有Eigen对象作为参数的函数,而不使用不必要的临时对象.人们可以在这里读到这一点.

当进一步搜索互联网时,我使用Ref <>类找到了几个不同的参数声明.在Eigen文档中,它们const Eigen::Ref<const Eigen::MatrixXf>&用于第一个示例中的只读参数.在第二个例子Eigen::Ref<Eigen::MatrixXd>中引入了读写参数,这里BUT const Eigen::Ref<const Eigen::MatrixXd>用于只读参数(无引用).所以我的问题是:

以下声明和我何时使用它有什么区别?`

  1. const Eigen::Ref<const Eigen::MatrixXd>&
  2. const Eigen::Ref<const Eigen::MatrixXd>
  3. const Eigen::Ref<Eigen::MatrixXd>&
  4. const Eigen::Ref<Eigen::MatrixXd>
  5. Eigen::Ref<const Eigen::MatrixXd>&
  6. Eigen::Ref<const Eigen::MatrixXd>
  7. Eigen::Ref<Eigen::MatrixXd>&
  8. Eigen::Ref<Eigen::MatrixXd>

为了完整性,我列出了const使用和参考的每种可能组合.

c++ parameters pass-by-reference eigen eigen3

21
推荐指数
1
解决办法
4478
查看次数

标签 统计

c++ ×1

eigen ×1

eigen3 ×1

parameters ×1

pass-by-reference ×1