Using gcc 9.4.0 and Eigen 3.3.7, the following compiles without issue:
#include <Eigen/Dense>
int main(int Argc, char *Argv[]) {
Eigen::Matrix<int, 1, 4> d = {1, 2, 3, 4};
}
Increasing the length by 1 provokes an error:
#include <Eigen/Dense>
int main(int Argc, char *Argv[]) {
Eigen::Matrix<int, 1, 5> d = {1, 2, 3, 4, 5};
}
foo.cpp:6:48: error: could not convert ‘{1, 2, 3, 4, 5}’ from ‘<brace-enclosed initializer list>’ to ‘Eigen::Matrix<int, 1, 5>’
6 | Eigen::Matrix<int, 1, 5> d = {1, 2, 3, 4, 5};
| ^
| |
| <brace-enclosed initializer list>
The second case is a copy of a line from the Eigen tutorial page.
Can someone explain the problem with the 2nd case?
UPDATE: Based on comments below, this appears to be a bug in the Eigen library. I've submitted a bug report.
UPDATE UPDATE: Per answer below, Eigen 3.3 specifically allows brace initializers up to 4 parameters, while Eigen 3.4 allows general brace initialization. The Mint distro version is 3.3 (a year after 3.4 released!) while the Eigen documentation now refers to the 3.4 version.