Eigen引入了用于将Eigen对象的函数作为参数编写的参数,而不需要使用不必要的临时对象,而不需要编写模板函数。人们可以阅读关于这个here。正确使用Eigen :: Ref <>类
当进一步搜索互联网时,我发现使用Ref类的参数有几个不同的声明。在Eigen文档中,他们使用const Eigen::Ref<const Eigen::MatrixXf>&
作为第一个示例中的只读参数。在第二个示例中,引入了Eigen::Ref<Eigen::MatrixXd>
用于读写参数,但此处const Eigen::Ref<const Eigen::MatrixXd>
用于只读参数(无参考)。所以我的问题是:
是什么下面的声明之间的差异,做时,我使用的`
const Eigen::Ref<const Eigen::MatrixXd>&
const Eigen::Ref<const Eigen::MatrixXd>
const Eigen::Ref<Eigen::MatrixXd>&
const Eigen::Ref<Eigen::MatrixXd>
Eigen::Ref<const Eigen::MatrixXd>&
?
Eigen::Ref<const Eigen::MatrixXd>
Eigen::Ref<Eigen::MatrixXd>&
Eigen::Ref<Eigen::MatrixXd>
为了完整性I所列常量使用和参考的每个可能的组合。
就我个人而言,对于读写参数,我会使用'const Eigen :: Ref作为只读参数和'Eigen :: Ref '。但我不确定引用('&')。 –