Vectorizing computation
13 Feb
2015
13 Feb
'15
2:51 a.m.
Hi, I would like to vectorize the next computation: nx, ny, nz = 720, 180, 3 outheight = np.arange(nz) * 3 oro = np.arange(nx * ny).reshape((nx, ny)) def compute1(outheight, oro): result = np.zeros((nx, ny, nz)) for ix in range(nx): for iz in range(nz): result[ix, :, iz] = outheight[iz] + oro[ix, :] return result I think this should be possible by using an advanced use of broadcasting in numpy. Anyone willing to post a solution? Thanks, -- Francesc Alted
3332
Age (days ago)
3332
Last active (days ago)
4 comments
2 participants
participants (2)
-
Francesc Alted
-
Julian Taylor