> -2- Now with the code below I have strange result. > With w=h=400: > - Using "slice" => 0.99 sec > - Using "numpy.ogrid" => 0.01 sec
It is not equivalent. The ogrid version only uses diagonal elements, and does less work. > It seems "ogrid" got better performance, but broadcasting is not working > any > more. Broadcasting is working, but not the way you think. Ogrid is not a faster alternative to slicing. You have the same in Matlab. You can index with a slice, an array of indices, or an array of booleans. If you are going to use the second alternative, the shape of the index arrays -- in each dimension -- must equal that of the output. You cannot use a "meshgrid" with different shaped arrays of x, y and z indices. NumPy is no different from Matlab here. _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion