|Re: [eigen] Multi Dimensional Arrays|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Multi Dimensional Arrays
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Tue, 8 Feb 2011 21:45:18 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=NnnAyfinUWL3Dsuc7WL0pNGajzTpBzRGzJjt2hJl+dc=; b=EQAUWmho9cMFyuMaKATdMKkxdK4lpZAgtyDF1L+zLdaRHF+FRykKN7SmRwNbdRX/sQ iKl/ku7UbyDJluZYPSKMZV5JdS35VQntIz0r+SYeVb8SM+O5Jav0f5rzcVhaCgm2iYxN OSozokUywt2f2roEfFx60Q8KonBY8En4zlcEw=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=DVnOIjIXKIcmmY3YA91ScrZxsYty1xB/oaDSyvso3dZpBms56TREfSr7LOTJtigSUD c+m3Kj3fnhU6xOjtFarn3LReD+V4BSBBNRwu8hwBS9cHhtX8jJ1BrGOQFZ0XSf0PgGiv 0b3/W0rEkpiiP47TtYQhKi1DMqsXfxojQDIos=
2011/2/8 Jim Bosch <talljimbo@xxxxxxxxx>:
> On 02/08/2011 05:13 PM, Andy Somogyi wrote:
>> From what I understand, the only way to handle multi dimensional
>> arrays with Eigen is something along the lines of
>> Array<Array<double,Dynamic,Dynamic> ,Dynamic, Dynamic> ...
>> This is really far from ideal as it really is an array of arrays
>> (separate memory blocks). Has there been any talk of merging in some
>> multi dimensional support to Array, say from the now defunct blitz++
>> code, or adding it a new?
> That's not entirely true; while Eigen is limited to 2 dimensions,
> Eigen::Matrix is not an array of arrays - they're allocated as a single
> memory block.
But here he's talking about Array<Array<double,Dynamic,Dynamic>
,Dynamic, Dynamic> and he's right to say that each
Array<double,Dynamic,Dynamic> would be separately dynamically
Using Array as scalar type is only going to be efficient for fixed
sizes (on the inner array type that's used as scalar type). And even
that will only get really efficient in Eigen 3.1, see
>> I really really really just want to use A SINGLE LIBRARY, and have to
>> rely on Eigen for linear algebra, and boost multi-array or blitz++
>> for multi-dimensional arrays. What would be nice is to have a
>> multi-dim array, be able to grab a dimension or sub-array out of it,
>> and use it directly as an Eigen Array / Matrix.
> I feel your pain, and I've been working on a multidimensional array library
> that's designed to let Eigen do all the matrix math:
> While that isn't the complete solution solution you're looking for, at least
> it's a clear division of labor.
> Essentially, while you can make an ndarray::Array of any dimension, you can
> view 1- or 2-dimensional subarrays of those as Eigen-conforming objects, or
> construct ndarray views into Eigen::Matrix objects.
This is a good approach, I'd like to encourage you in this direction.
I almost wrote back to the list to suggest that this might be the best
approach to take balancing reasonable performance with reasonable ease
Like with matrices, the hard part is products. The name of the game is
memory locality / cache friendliness. By leveraging Eigen's optimized
matrix product implementation and applying it to 2-dimensional slices
in your N-dim arrays, you should be able to get somewhere. Depending
on the storage order/ cases, you may have to copy slices into
temporaries to have them contiguously stored in memory.
> That won't get you all the way there if your main application is
> multidimensional tensor contractions, but it does provide a nice interface
> for interfacing with Python/Numpy and moving Eigen-compatible objects around
> with reference counting instead of deep copies.
> Good Luck!
> Jim Bosch