Boost logo

Boost :

Subject: Re: [boost] Interest in multi-dimensional array class templates.
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2011-06-20 04:00:22


On 19/06/2011 22:57, Brian Smith wrote:

>> Can I look at a N-dimensional array as a M-dimensional array, with M>
>> N? With N< M?
>>
> An M-dimensional array is an N-dimensional array, for all M = N.

That's not what I asked.

>
>> Can I have a view of part of the array? Can I easily linearize or
>> reshape it?
>>
> Yes. If you mean by linearization, can it be allocated with a single
> memory request then no. I did write such a type and it was pretty
> efficient but I removed it. Reshaping a view is possible though.

No, I mean an operation that linearizes the element in a 1-dimensional
structure.

>> Given another N-dimensional array whose values are positions, can I
>> obtain the array of the values accessed at the given positions?
>>
> With some effort on your behalf yes.

It should be easy to use.

>> Can this be a lazy view?
>>
> Probably depends on how your program is structured.

Why would it have to depend on it?

>> How does it integrate with range and iterators?
>>
> Iterators we're also implemented as separate classes then removed in
> favour of the view. The reason being they proved detremental to
> performance, maybe an implementation detail, nevertheless for the time
> being their gone. Ranges are a part of the view and iterators returned
> by classes are good old fashioned pointers that are owned by class
> that returns them.

If you had performance problems, maybe you did it wrong.

Iterators are important for integration with existing algorithms. Both
outer dimension iteration and linear iteration are necessary to have.

> I'm not familiar with Matlab syntax so can't comment.

You'll find here a list of a couple of reshaping and slicing operations
with their Matlab and SciPy syntax.

<http://www.scipy.org/NumPy_for_Matlab_Users#head-13d7391dd7e2c57d293809cff080260b46d8e664>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk