[SciPy-User] Avoiding inner for loops??

Martin De Kauwe mdekauwe@gmail....
Mon Aug 20 20:11:22 CDT 2012


Or perhaps an easier solution would be to build the sampling grid first and 
then use a single for loop to run the model?

import itertools
import numpy as np

grid_size = 500
a = np.linspace(5.0, 350, grid_size) 
b = np.linspace(5.0, 550, grid_size) 
c = np.linspace(1E-8, 10.5, grid_size)

x = []
for (i,j,k) in itertools.product(a, b, c):
    x.extend((i,j,k))

This would achieve what I want but is again very slow, so is there a way to 
jump over the need for the two inner loops?

thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20120820/fadf5e0b/attachment.html 


More information about the SciPy-User mailing list