|
Boost : |
From: rwgk_at_[hidden]
Date: 2001-03-28 18:16:33
Another related web page that might be worth studying is
the Python Enhancement Proposal for multi-dimensional arrays:
http://python.sourceforge.net/peps/pep-0209.html
Ralf
--- In boost_at_y..., "David Abrahams" <abrahams_at_m...> wrote:
> I've been looking at the Numerical Python (NumPy) project at
> http://sourceforge.net/projects/numpy/, in part to see what
operations
> others have found useful. Here are just some slicing and dicing
operations
> allowed with NumPy:
>
> # a is 2-dimensional
> a[2:7,3] # rows 2-6, column 3
> a[:7,3] # rows 0-6, column 3
> a[:7:2,3] # rows 0,2,4 and 6, column 3
> a[-1,3] # the last row, column 3
> a[-4:,3] # the last 4 rows, column 3
> a[7::-1,3] # rows 7,6,5,4,3,2,1, and 0, column 3
> a[7::-2,3] # rows 7,5,3, and 1, column 3
> a[:,3] # all rows, column 3
>
> # b is N-dimensional
> b[...,:2] # all of the first N-1 dimensions, the first 2 elements
of the
> last
> a[:,NewAxis] # adds a new axis of dimension 1 to the end of a's
shape
> a[1][:,NewAxis] # a's first row as a column
> b[...,NewAxis,:] # inserts a new axis before the last axis in b's
shape
>
>
> -Dave
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk