I want to "reserve" dense Eigen::MatrixXd, because I can't know the number of rows beforehand. However, "resize" function changes its address and its value dynamically. Is there any idea?
resize.cpp
#include <Eigen/Dense>
#include <iostream>
using namespace std;
using namespace Eigen;
int main(void) {
VectorXd m;
for (int i = 0; i < 5; i++) {
m.resize(m.size()+1);
m(i) = i;
cout << m << endl;
for (int j = 0; j < m.size(); j++) {
cout << &m(j) << endl;
}
}
return 0;
}
output
0
0xb34010
0
1
0xb34010
0xb34018
0
1
2
0xb34010
0xb34018
0xb34020
5.80399e-317
4.94066e-324
2.122e-314
3
0xb34030
0xb34038
0xb34040
0xb34048