Created attachment 406 [details]
Makes CommaInitializer a true expression template
Please also see http://forum.kde.org/viewtopic.php?f=74&t=117882 for the forum discussion on this.
With the help of Gael I prepared a patch that makes CommaInitializer a true expression template. This permits syntax such as:
typedef Eigen::VectorXd Vector;
Vector vector = (Vector(3) << 1, 2, 3); // Initialization from a temporary
functionCall(a, b, (Vector() << 1, 2, 3)); // Passing into a function
without the use of .finished(). This is nice because when doing a lot of inline vector/matrix creation, using .finished() is tedious.
I'm not very experienced at modifying Eigen's internal code, so this patch should be checked by someone more experienced. I verified this works using project code using Eigen on MSVC 11.0 and gcc 4.7.3.
Also, what documentation and unit tests need to be modified to account for this change?
Created attachment 502 [details]
New patch with unit tests
I'm finally working on creating unit tests for this patch, but have found that changes in Eigen render this code no longer working. I already added an ExpressionType typedef (modeling after the Block class), but am still getting another compile error (below). I've spent some time trying to understand what's going on but am getting lost in the template internals of Eigen. I would really appreciate if someone is able to apply the patch, look at the modified CommaInitializer class it creates, and try to point out what has changed that is missing?
For context, this patch is to make CommaInitializer a real expression template, so that it can be passed into functions and assigned directly to variables without using .finished().
In file included from /Users/richard/src/eigen/test/commainitializer.cpp:10:
In file included from /Users/richard/src/eigen/test/main.h:220:
In file included from /Users/richard/src/eigen/Eigen/QR:4:
In file included from /Users/richard/src/eigen/Eigen/Core:322:
/Users/richard/src/eigen/Eigen/src/Core/CoreEvaluators.h:92:27: error: implicit instantiation of undefined
template 'Eigen::internal::unary_evaluator<Eigen::CommaInitializer<Eigen::Matrix<double, 3, 3, 0, 3, 3> >,
struct evaluator : public unary_evaluator<T>
-- GitLab Migration Automatic Message --
This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.
You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/716.