mercredi 23 octobre 2019

How to fix 'non-type template argument is not a constant expression' in eigen3?

I am still new to the Eigen library and C++. I am testing some code and I do not get why this

#include <iostream>
#include <Eigen/Dense>

using namespace std;

int main()
{
  int a = 2;
  const int SIZE_ = a;
  Eigen::Matrix<float, SIZE_, SIZE_> test;
  return 0;
}

does not compile, while this

#include <iostream>
#include <Eigen/Dense>

using namespace std;

int main()
{
  const int SIZE_ = 2;
  Eigen::Matrix<float, SIZE_, SIZE_> test;
  return 0;
}

works perfectly fine. How could I change the first code so that it works (i.e. SIZE_ would be initiated by a variable that potentially could have a different value).

Cheers!

Aucun commentaire:

Enregistrer un commentaire