#include <Eigen/Core>
#include <Eigen/Array>
#include <Eigen/LU>
#include <Eigen/Cholesky>
#include <iostream>
using namespace Eigen;
typedef Matrix<double, Dynamic, Dynamic, RowMajor> Mat;
typedef Matrix<double, Dynamic, 1> Vec;
int main() {
Mat A(5, 5);
A..setRandom();
double bs[] = {1, 2, 3, 4, 5};
double xs[5];
Map<Vec> b(bs, 5);
Map<Vec> x(xs, 5);
A.part<UpperTriangular>().ldlt().solve(b, &x);
A.lu().solve(b, &x);
std::cout << "solution:\n" << x << "\n";
}
In file included from /usr/include/eigen2/Eigen/Cholesky:36,
from lu_regression.cc:7:
/usr/include/eigen2/Eigen/src/Cholesky/LDLT.h: In member function ‘const Eigen::LDLT<typename Eigen::MatrixBase<Derived>::PlainMatrixType> Eigen::MatrixBase<Derived>::ldlt() const [with Derived = Eigen::Part<Eigen::Matrix<double, 10000, 10000, 1, 10000, 10000>, 1024u>]’:
lu_regression.cc:25: instantiated from here
/usr/include/eigen2/Eigen/src/Cholesky/LDLT.h:195: error: conversion from ‘const Eigen::Part<Eigen::Matrix<double, 10000, 10000, 1, 10000, 10000>, 1024u>’ to non-scalar type ‘const Eigen::LDLT<Eigen::Matrix<double, 10000, 10000, 3, 10000, 10000> >’ requested