Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2001-03-27 15:35:00


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