eigen :: llt<eigen :: matrixxd>具有不完整的类型

Eigen::LLT< Eigen::MatrixXd > has incomplete type

本文关键字:eigen 类型 gt llt lt matrixxd      更新时间:2023-10-16

查看此代码。在Ubuntu上编译...

MatrixXd A(3,3);
A << 4,-1,2, -1,6,0, 2,0,5;
cout << "The matrix A is" << endl << A << endl;
LLT<MatrixXd> lltOfA(A); // compute the Cholesky decomposition of A

这是一个医生案例:

#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include <doctest/doctest.h>
#include <Eigen/Core>
TEST_CASE("llt")
{
  Eigen::MatrixXd A(3,3);
  A<<1,2,3,4,5,6,7,8,9;
  Eigen::LLT<Eigen::MatrixXd> lltof(A);
}

汇编失败了:

/src/test/test-proto.cc:40:38: error: variable ‘Eigen::LLT<Eigen::Matrix<double, -1, -1>, 1> lltof’ has initializer but incomplete type
   Eigen::LLT<Eigen::MatrixXd> lltof(A);

什么给?从我的代码中缩小了这一点,以完全表示文档。

糟糕。测试案例应为:

#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include <doctest/doctest.h>
#include "proto.h"
#include <Eigen/Dense> //NOT Eigen/Core
TEST_CASE("llt")
{
  Eigen::MatrixXd A(3,3);
  A<<1,2,3,4,5,6,7,8,9;
  Eigen::LLT<Eigen::MatrixXd> lltof(A);
}

请注意#include的更改。

愚蠢的错误,但我将其留给我未来的自我/Google。

引用此链接的示例

struct Y {};
template<const Y& b> struct Z {};
Y y;
Z<y> z;  // ok: no conversion

您最好理解模板非类型的参数。