Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2000-12-03 15:35:00


The Matlab reshape() function creates a new array with the specified
dimensions, and copies the data from the old array into the new, mapping
elements in a fairly straightforward way.

Perhaps what you had in mind in your reply is changing the number of
dimensions of an array "in-place". This is certainly possible in terms of
creating an ArrayRef... creating an ArrayRef with a different number of
dimensions than the underlying Array. The only restriction is that the
total number of elements needs to stay constant. One special case of this
functionality would be flattening an N-dimensional array into a single
dimensional array.

Another related issue to consider (perhaps you were alluding to this in
your email) is whether it is really necessary/desirable to encode the
number of dimensions as a template parameter of the array class. I can
imagine an implementation of the operator[] proxy just encoding the
current dimension as a run-time integer instead of a template parameter. I
wonder if there would be performance differences? Are there any other
trade-offs to consider? code size, compilation speed, etc.

Cheers,
Jeremy

On Sun, 3 Dec 2000, Giovanni Bavestrelli wrote:

> --- In boost_at_[hidden], Jeremy Siek <jsiek_at_l...> wrote:
> >[...]
> > For example, one data-point to look at is how Matlab handles
> > multi-dimensional arrays. Here's a look at indexing into a 2x2x2
> cube in
> > various ways using matlab.
> >
> > >> a = [1,2,3,4,5,6,7,8]
> > a =
> > 1 2 3 4 5 6 7 8
> >
> > >> b = reshape(a, 2, 2, 2)
>
> Does that mean that with Mathlab you can reshape a monodimensional
> array into a three dimensional array, or, in general, change the
> number of dimensions of the array? With my Array that's certainly not
> possible, and I don't know if it's desirable. The whole
> implementation would have to change to support that, and many
> problems would have to be addressed.
>
> Giovanni Bavestrelli
>
>
>
>
>

----------------------------------------------------------------------
 Jeremy Siek www: http://www.lsc.nd.edu/~jsiek/
 Ph.D. Candidate email: jsiek_at_[hidden]
 Univ. of Notre Dame work phone: (219) 631-3906
----------------------------------------------------------------------


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