4

Is there an operator or function in Eigen to read the elements of a vector or matrix into separate variables? For example I imagine the converse of the comma-initializer:

Eigen::Vector5d v;
v << a, b, c, d, e;
// ... do something with v ...
v >> a, b, c, d, e; // is there a way to do what I'm trying to do here, in one simple line?

The only way I know of is a 5-liner:

a = v(0);
b = v(1);
c = v(2);
d = v(3);
e = v(4);
Museful
  • 6,711
  • 5
  • 42
  • 68
  • There is a pending PR to add structured bindings to Eigen: https://bitbucket.org/eigen/eigen/pull-requests/541/add-structured-bindings-support/ – chtz Nov 29 '19 at 10:37

0 Answers0