Ex: adding two arrays
n = 100
x = np.random.rand(n)
y = np.random.rand(n)
f = []
for i in range(100):
f.append(x[i] + y[i])
x = np.rand(100)
y = np.rand(100)
f = x + y
Under the hood, complex operations will automatically be run on multiple processors.
conda install mkl
Finite Difference Examples: diffusion.py
1-D
In [ ]:
# run these functions in iPython to see some
from diffusion import *
%timeit diff1d_loop(n_x=1000, plotUpdate=False, showPlots=False)
%timeit diff1d_vec(n_x=1000, plotUpdate=False, showPlots=False)
In [ ]:
%timeit diff2d_loop(n_x=100, plotUpdate=False, showPlots=False)
%timeit diff2d_vec(n_x=100, plotUpdate=False, showPlots=False)
In [ ]:
from motion_points import *
%timeit simulateParticles_loop(showPlots=False)
%timeit simulateParticles_vec(showPlots=False)
In [ ]:
x = np.random.rand(10, 100)
y = x.ravel()
print x.T.shape
print y.shape
print y.reshape(x.shape).shape
print 'x flags:\n', x.flags
print 'y flags:\n', y.flags
In [4]: