[SciPy-user] more for loops removal

Emanuele Zattin emanuelez at gmail.com
Mon Aug 6 06:04:22 EDT 2007


this time it is something like this:

paths = []
for i in range(d12.shape[1]):
   for j in range(d23.shape[1]):
      for k in range(d34.shape[1]):
         if d12[0,i] == d23[1,j] and d23[0,j] == d34[1,k]:
            paths.append([d12[1,i], d12[0,i], d23[0,j], d34[0,k]])

i will explain... d12, d23, d34 contain indices that say that a path
from index1 in 1 to index2 in 2 is plausible.
what i want to do now is to find which are the complete paths from 1 to 4.

is it possible to once again use broadcasting to speed things up?

-- 
Emanuele Zattin
---------------------------------------------------
-I don't have to know an answer. I don't feel frightened by not
knowing things; by being lost in a mysterious universe without any
purpose — which is the way it really is, as far as I can tell,
possibly. It doesn't frighten me.- Richard Feynman



More information about the SciPy-User mailing list