From the Eigen Tutioral about Matrix
Of course, Eigen is not limited to matrices whose dimensions are known
at compile time. The RowsAtCompileTime and ColsAtCompileTime template
parameters can take the special value Dynamic which indicates that the
size is unknown at compile time, so must be handled as a run-time
variable. In Eigen terminology, such a size is referred to as a
dynamic size; while a size that is known at compile time is called a
fixed size. For example, the convenience typedef MatrixXd, meaning a
matrix of doubles with dynamic size, is defined as follows:
typedef Matrix<double, Dynamic, Dynamic> MatrixXd;
And similarly, we define a self-explanatory typedef VectorXi as
follows:
typedef Matrix<int, Dynamic, 1> VectorXi;
You can perfectly have e.g. a fixed number of rows with a dynamic
number of columns, as in:
Matrix<float, 3, Dynamic>
Here is an example I just quickly made:
Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic> myMatrix;
myMatrix.resize(1, 1);
myMatrix(0, 0) = 1.0;
myMatrix.resize(2, 2);
myMatrix(1, 1) = 1.0;
myMatrix.resize(3, 3);
myMatrix(2, 2) = 1.0;
myMatrix.resize(4, 4);
myMatrix(3, 3) = 1.0;