查看this code。在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);怎么回事?这是从我的代码中删减出来的,以便准确地表示文档。
发布于 2019-02-20 09:32:50
糟了。测试用例应该是:
#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中的更改。
愚蠢的错误,但我会把它留给我未来的自己/谷歌。
发布于 2019-02-20 09:48:26
对此link示例的引用
struct Y {};
template<const Y& b> struct Z {};
Y y;
Z<y> z; // ok: no conversion你最好理解模板的非类型参数。
https://stackoverflow.com/questions/54777491
复制相似问题