简体   繁体   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> >’

I'm using the Eigen library in C++ to obtain the square root of a float square matrix: 我在C ++中使用Eigen库获取浮点方阵的平方根:

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

  auto sqrtG = gPrime.sqrt();

when I compile it I got the following error: 当我编译它时,出现以下错误:

.../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;
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~

What does 'incomplete type' mean and what should I do to fix it? “不完整类型”是什么意思,我应该怎么做才能解决?

I'm using C++ 11 and g++ 8.1.1. 我正在使用C ++ 11和g ++ 8.1.1。

Searching for the documentation of that function reveals that it is part of Eigen-unsupported and (at the top) 搜索该函数文档表明它是Eigen不支持的一部分,并且(在顶部)

To use this module, add 要使用此模块,请添加
#include <unsupported/Eigen/MatrixFunctions>
at the start of your source file. 在源文件的开头。

invalid use of incomplete type 无效使用不完整类型

means that the compiler only finds a declaration but a definition is required at the point of use. 意味着编译器仅找到一个声明,但在使用时需要定义。

Looks like its looking for something more than the P_old.sqrt(), you will need to have a look at what this object looks like, it might have getters/setters or atomic types you might need to use. 看起来它在寻找除P_old.sqrt()之外的东西,您需要查看该对象的外观,它可能需要使用getter / setter或原子类型。

Read up about forward declarations to understand why you got this error, fixing it should be straightforward. 阅读有关前向声明的文章,以了解为什么会出现此错误,并应直接进行修复。

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

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