Excuse me, I am a beginner in C++. So I do not use pointers. I need to convert a static 2d array of C++ into Eigen library format. I need to compute eigenvalues and eigenvectors of a large matrix since it is my applied problem.
My code is something like
double matr1[100][100];
MatrixXd copy_matr1;
for (int i = 0; i < 100; i++)
for (int j = 0; j < 100; j++)
matr1[i][j] = i + j;
copy_matr1 = Map<MatrixXd>(matr1);
or (with replacement of the last line with the next one)
copy_matr1 = Map<MatrixXd>(matr1, 100, 100);
But the last line is wrong. What is the correct notation?
But the code below (that converts a static 1d array of C++ into Eigen library format) is correct. I cannot understand where is a mistake in the previous snippet.
double arr1[100];
MatrixXd copy_arr1;
for (int i = 0; i < 100; i++)
arr1[i] = i + 10;
copy_arr1 = Map<MatrixXd>(arr1);
or (with replacement of the last line with the next one)
copy_arr1 = Map<MatrixXd>(arr1, 100);
Thank you very much in advance!