More on computing with NumPy arrays

Multi-dimensional arrays can be constructed:
x = zeros(n)               # array with indices 0,1,...,n-1
x = zeros((m,n))           # two-dimensional array
x[i,j] = 1.0               # indexing
x = zeros((p,q,r))         # three-dimensional array
x[i,j,k] = -2.1
x = sin(x)*cos(x)
We can plot one-dimensional arrays:
from scitools.easyviz import *  # plotting
x = linspace(0, 2, 21)
y = x + sin(10*x)
plot(x, y)
NumPy has lots of math functions and operations
SciPy is a comprehensive extension of NumPy
NumPy + SciPy is a kind of Matlab replacement for many people

previousnexttable of contents