I want to read data from a file into a matrix in Eigen. I have coded everything but there is one problem that I encounter. I don't know yet beforehand how many data points are in the file, so I want to be able to initialize a matrix without specifying its size. I know that the following way of intializing a matrix works in Eigen:
MatrixXd A;
But now if I then do for instance
A << 1, 2,
4, 7;
It doesn't work. I had hoped that it would recognise it as a 2x2 matrix in this example, so that I could then work with it. So basically my question is, how can I add data to A, without having to specify its size?
here
?Matrix3f m; m << 1, 2, 3, 4, 5, 6, 7, 8, 9; std::cout << m;
that is the code. Can you tell what do you mean by doesn't work. – EpigoneMatrix3f
, that's not the same, the 3 already specifies the size. – TellezMatrix3f
. I don't want to do that. If you look at my syntax, I specifiedMatrixXd
so I have an 'X' where they have a '3' indicating that the size is unknown. – Tellez