I am trying to write code that needs to define a matrix size based upon an input. A stripped down version of the code that shows the issue is:
#include <iostream>
#include "eigen/Eigen/Dense"
#include <cmath>
using namespace Eigen;
void matrixname( const int numbRow, const int numbcol);
int main()
{
const int numbRow=5;
const int numbCol=3;
matrixname(numbRow,numbCol);
return 0;
}
void matrixname( const int numbRow, const int numbCol)
{
Matrix<double,numbRow,numbCol> y;
}
When attempting to compile the code, the following error is returned:
/main.cpp:20:15: error: non-type template argument is not a constant expression
The build breaks in the last line of trying to define y.
Is there any way I can modify the declaration or passing of the variables in order to be able to define the size of the matrix in this way?