Boost logo

Boost :

Subject: Re: [boost] Interest in multi-dimensional array class templates.
From: Brian Smith (bjs3141_at_[hidden])
Date: 2011-06-21 06:08:48


I would like to take the opportunity to re-reply to the questions you
posed here. My initial thoughts were that the questions were directed
in a rather disinterested manner since a couple of examples using the
library would have given you some if not all of the answers you
sought. However on reflection I now think that this was probably not
the case and hope you will accept my apologies and allow me to give a
more measured response.

On 6/20/11, Mathias Gaunard <mathias.gaunard_at_[hidden]> wrote:
> 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.
>
It is possible to view lower dimensional parts of an N-dimensional
array, i.e., for M < N.

>>
>>> 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.
>
I'm still not quite sure if I understand this correctly. It is
possible to produce a view containing the addresses of sequences of
data elements from an array that will be allocated in a continuous
block of memory. The values can accessed and altered via the view
using indexing or linear iteration using the begin and end methods of
the view. Alternatively instead of addresses, values from an array can
be stored in a view and then worked on as desired again via the view.
The altered values can then be inserted back into the array, or to
another suitably defined array, at the positions corresponding to the
view's stored ranges over the array.

>
>>> 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.
>
It is.
>
>>> Can this be a lazy view?
>>>
>> Probably depends on how your program is structured.
>
> Why would it have to depend on it?
>
Again I don't entirely get what you mean here, could you elaborate.

>
>>> 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.
>
If you look back a few lines you will see that, that is essentially
what I said. The operative word though is maybe, since maybe the
iterator implementation is inherently inferior to the implementation
provided by the view. This was certainly the case when comparing the
two. The reason 'maybe' is there follows from the fact that an
alternative implementation of iterators may well have improved
performance although what I had at the time looked fine.

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

>
>> 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>
>
I've had a quick look and nothing like the colon method of producing
slices is available. Some of the other stuff is similar, I would
suggest you try the library and see what is available. If any
questions remain feel free to ask.

>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>

-- 
www.maidsafe.net

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