Check out this code. Compiled on 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
Here's a doctest case:
#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);
}
Compilation fails with:
/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);
What gives? This is reduced from my code to exactly represent the documentation.
Oops. Test case should be:
#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);
}
Note the change in #include
.
Dumb mistake, but I'm leaving it up for my future self / google.