Re: [eigen] Best practices for accessing named regions within a larger array? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Best practices for accessing named regions within a larger array?
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Sat, 3 Dec 2011 11:30:23 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=/40LxdtirKtOMPFShOOaFzP+6yn37GhdR76STTCSknQ=; b=e2FnmYLzmziuaWU4xwRgwteetCe22M6jPugqt6dLMVHN5yBqywAwotqUKUzPGPmiNp 18M6pVp5kvJkDTqTmTZMYOPebWgdFUr91GXCg1K/UFlnDmqU6OV0e2WBsIMvlb/2Ej34 HldBPX4w8wJNBm0hj7lz28p9+QZjLYtbRMhW4=
Hi Rhys,
I'm not sure to understand your issue. Do you have a concrete example
of the "error-prone boilerplate" you are talking about?
cheers,
gael
On Tue, Nov 22, 2011 at 12:05 AM, Rhys Ulerich <rhys.ulerich@xxxxxxxxx> wrote:
> 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
> elegant?
>
> Thanks,
> Rhys
>
>