This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 716 - Patch for making CommaInitializer a true expression template
Summary: Patch for making CommaInitializer a true expression template
Status: NEW
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - expression templates (show other bugs)
Version: 3.2
Hardware: All All
: Normal enhancement
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 3.x
  Show dependency treegraph
 
Reported: 2013-12-16 22:56 UTC by richard.jw.roberts
Modified: 2019-12-04 12:52 UTC (History)
3 users (show)



Attachments
Makes CommaInitializer a true expression template (3.33 KB, patch)
2013-12-16 22:56 UTC, richard.jw.roberts
no flags Details | Diff
New patch with unit tests (1.90 KB, patch)
2014-10-25 22:30 UTC, richard.jw.roberts
no flags Details | Diff

Description richard.jw.roberts 2013-12-16 22:56:49 UTC
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?
Comment 1 richard.jw.roberts 2014-10-25 22:30:36 UTC
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> >,
      Eigen::internal::IndexBased, double>'
struct evaluator : public unary_evaluator<T>
Comment 2 Nobody 2019-12-04 12:52:53 UTC
-- 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.

Note You need to log in before you can comment on or make changes to this bug.