Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2000-12-02 21:01:43


On Sat, 2 Dec 2000, Giovanni Bavestrelli wrote:
> I think this is part of a very important issue. Should we see an N
> dimensional array as a container of elements, or as a container of N-
> 1 dimensional arrays? It really is both, but which view simplifies

Right, we certainly need to support both "views". We just need to decide
what is the best syntax to use. In this regard, there's much cultural
history to consider.

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)
b(:,:,1) =
     1 3
     2 4
b(:,:,2) =
     5 7
     6 8

>> b(1,1,1)
ans =
     1

>> b(2,2,2)
ans =
     8

>> b(1,:,1)
ans =
     1 3

>> b(4)
ans =
     4

Cheers,

Jeremy

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