This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Computing multiple expressions efficiently

Tags: None
(comma "," separated)
marmadukew
Registered Member
Posts
1
Karma
0
Hi,

A question from a new Eigen user (not well versed in C++ either):

I understand that Eigen can, for a few arrays a, b & x, turn a statement like
Code: Select all
y = a*x + b;

into a single for loop which does not create temporary arrays (and I hope writes elements directly into y). This is a huge advantage for large arrays. However, often I have the use case of evaluating multiple expressions, cwise, involving the same arrays, for example the two RHS of differential equations for a nonlinear oscillator:
Code: Select all
dxdt = tau * (x - x*x*x + y);
dydt = (a - x)/tau;

In this case, is Eigen able to perform the two statements in a single for loop? If not, is there a shorter way to do this than writing the for loop by hand?

Thanks for your advice.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Indeed, in such a case, if your vectors do not fit within L1, fusing the two loops might be useful, however, this is not possible in Eigen yet. If you write the loops yourself, then you will loose Eigen's explicit vectorization and so you might loose speed despite fewer cache misses.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
For the record I opened a feature request for discussion: http://eigen.tuxfamily.org/bz/show_bug.cgi?id=984


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]