Re: [eigen] Multi Dimensional Arrays

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


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
>>>
>>>
>>>
>>
>>
>
>
>
>



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