Re: [eigen] Multi Dimensional Arrays |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Multi Dimensional Arrays
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Wed, 9 Feb 2011 10:10:30 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type:content-transfer-encoding; bh=3mJpj3HWH3MOCYuA+hhAWLkUSDuB2K9oeM9vFDr9Cw0=; b=ooG023UNq0KKWmmQj8KYNeqmtc8BVUek6fBgQAvFoa/WS5wkgAAVj/t89mvltBXFcZ 5+KHcIK3d4K2vU6lLiwKpnCpnSSNb8CyO4B3pALBUkyR3jX00lBBYJUtz/eWF08I9acP bcfq/MROR0vQhIoP4JCGV97WupPU1YQMQwrrk=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=dMldoGP+uVhUS3Sy4zczUQBGTZl8ozzrTIjZyD5FXY1XsY7y1ScTpglDK165XIhcj0 hu0XJ15Ou253rUDmm9nDfemlawPJneXIYS6Pz86h9REfxYw/0/W837si2ZbO+gBU8CH7 20bY69EcNodVxrD8d0f9o5o5iuKQ9XrAp0364=
I also believe that the best way to add support multi-dim array and/or
tensor in Eigen is to write a dedicated module on top of the core
module. The difficulty of this task hardly depends on the targeted
generality. Typically, with the following assumption, this should not
be too difficult at all:
- dynamic sizes only
- compile time dimensionality only
- rectangular dense only
- ...
On the other hand, supporting both fixed and dynamic sizes looks very
very painful, though this could be quite useful for some applications.
Also note that our product routines already automatically pack the
input matrices to optimize the performance, so no need to do it at a
higher level. The only missing bit, is that currently we don't allow
2D objects with strides in both directions.
Jim: I take note of your "mat[view(start1,end1)()(start3,end3)]"
syntax for sub arrays/ranges which is pretty elegant IMO.
gael
On Wed, Feb 9, 2011 at 5:31 AM, Jim Bosch <talljimbo@xxxxxxxxx> wrote:
> On 02/08/2011 06:45 PM, Benoit Jacob wrote:
>>>
>>> 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:
>>>
>>> http://code.google.com/p/ndarray/
>>>
>>> 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
>> of implementation.
>>
>> 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.
>>
>
> It occurs to me that the bridge point for this might be an Eigen::Map-like
> object that supports arbitrary strides in *both* dimensions, and copies as
> necessary for performance; that would make it possible to efficiently
> operate on any two dimensions of a higher-dimensional array with Eigen.
> With something like that, a multidimensional array library really could
> offload almost all of the difficult optimizations to Eigen.
>
> Oh, and apologies to Andy for the earlier incorrect correction on
> arrays-of-arrays!
>
> Jim
>
>
>
>>
>>>
>>> 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
>>>
>>>
>>>
>>
>>
>
>
>
>