[eigen] Best practices for accessing named regions within a larger array?

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]

Hi all,

I keep running into use cases where I'd like to have a contiguous
array cut up into "named" subarrays of varying widths.

As a simplistic example, say I want Array<double, Dynamic, 5> to have
the leftmost column named "rho", the next three columns named "rhou",
and the final column named "rhoe".  That is, I'd like I'd like
foo.rho() to mean foo.leftCols<1>(), foo.rhou() to mean
foo.middleCols<3>(1), and foo.rhoe() to mean foo.rightCols<1>().
Having named regions within contiguous storage happens to be handy
within my simulation code for both memory access patterns and
readability purposes.

Accomplishing this by using either inheritance or containment of an
Eigen::Array instance and then adding inlined members is
straightforward, of course.  But both requires error-prone boilerplate
if the number of named views becomes large.  That error-prone
boilerplate can be traded for macros (a la Boost.Preprocessor) at the
expense of readability.

I've not yet found a simple, clean, extensible way to produce such
views methods.  Any suggestions or solutions that you've found


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/