繁体   English   中英

在C ++的Eigen库中,我该如何解决:无效使用不完整类型&#39;const class Eigen :: MatrixSquareRootReturnValue <Eigen::Matrix<float, -1, -1> &gt;”

[英]In C++'s Eigen library, how do I solve: invalid use of incomplete type ‘const class Eigen::MatrixSquareRootReturnValue<Eigen::Matrix<float, -1, -1> >’

我在C ++中使用Eigen库获取浮点方阵的平方根:

  MatrixXf gPrime(QUAD_EKF_NUM_STATES, QUAD_EKF_NUM_STATES);
  gPrime.setIdentity();

  auto sqrtG = gPrime.sqrt();

当我编译它时,出现以下错误:

.../src/QuadEstimatorEKF.cpp:255:31: error: invalid use of incomplete type ‘const class Eigen::MatrixSquareRootReturnValue<Eigen::Matrix<float, -1, -1> >’
   auto sqrtG = gPrime.sqrt()
                               ^
In file included from /.../lib/Eigen/Core:346,
                 from /.../lib/Eigen/Dense:1,
                 from /.../src/QuadEstimatorEKF.h:11,
                 from /.../src/QuadEstimatorEKF.cpp:2:
/.../lib/Eigen/src/Core/util/ForwardDeclarations.h:286:34: note: declaration of ‘class Eigen::MatrixSquareRootReturnValue<Eigen::Matrix<float, -1, -1> >’
 template<typename Derived> class MatrixSquareRootReturnValue;
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~

“不完整类型”是什么意思,我应该怎么做才能解决?

我正在使用C ++ 11和g ++ 8.1.1。

搜索该函数文档表明它是Eigen不支持的一部分,并且(在顶部)

要使用此模块,请添加
#include <unsupported/Eigen/MatrixFunctions>
在源文件的开头。

无效使用不完整类型

意味着编译器仅找到一个声明,但在使用时需要定义。

看起来它在寻找除P_old.sqrt()之外的东西,您需要查看该对象的外观,它可能需要使用getter / setter或原子类型。

阅读有关前向声明的文章,以了解为什么会出现此错误,并应直接进行修复。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM