Registered Member
|
Hi,
I am working on an expression template library for CFD applications. The aim is to support multiple existing vector expression template libraries as backends and write the code in a most generic way. However, Eigen (version 3.2. seems to have some problems when used in combination with the auto return type. The following demo code illustrates the problem. In fact, using auto return type to simply return one of the parameters (but not modify it) works well. However, using auto return type together with arithmetics (see last line of the main routine, where the velocity is computed by dividing the momentum by the density) leads to
Any help on combining the Eigen library with nested auto return types and arithmetics is highly appreciated. Kind regards, Matthias Möller
|
Moderator
|
This is because your momentum() and density() functions returns a copy of the input arrays which are then stored by reference by the quotient expression. Then the copies are deleted before the assignment to result takes place... The solution is to make sure your accessors returns by reference to the original objects.
|
Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft