Re: [Numpy-discussion] speed of numpy.ndarray compared to Numeric.array

2011-01-10 Thread EMMEL Thomas
To John: Did you try larger arrays/tuples? I would guess that makes a significant difference. No I didn't, due to the fact that these values are coordinates in 3D (x,y,z). In fact I work with a list/array/tuple of arrays with 10 to 1M of elements or more. What I need to do is to calculate

Re: [Numpy-discussion] speed of numpy.ndarray comparedtoNumeric.array

2011-01-10 Thread EMMEL Thomas
-Original Message- From: numpy-discussion-boun...@scipy.org [mailto:numpy-discussion- boun...@scipy.org] On Behalf Of David Cournapeau Sent: Montag, 10. Januar 2011 10:15 To: Discussion of Numerical Python Subject: Re: [Numpy-discussion] speed of numpy.ndarray compared

Re: [Numpy-discussion] numexpr with the new iterator

2011-01-10 Thread Francesc Alted
A Sunday 09 January 2011 23:45:02 Mark Wiebe escrigué: As a benchmark of C-based iterator usage and to make it work properly in a multi-threaded context, I've updated numexpr to use the new iterator. In addition to some performance improvements, this also made it easy to add optional out= and

Re: [Numpy-discussion] speed of numpy.ndarray compared to Numeric.array

2011-01-10 Thread Sebastian Berg
Hey, On Mon, 2011-01-10 at 08:09 +, EMMEL Thomas wrote: #~ def bruteForceSearch(points, point): minpt = min([(vec2Norm(pt, point), pt, i) for i, pt in enumerate(points)], key=itemgetter(0))

Re: [Numpy-discussion] numexpr with the new iterator

2011-01-10 Thread Francesc Alted
A Monday 10 January 2011 11:05:27 Francesc Alted escrigué: Also, I'd like to try out the new thread scheduling that you suggested to me privately (i.e. T0T1T0T1... vs T0T0...T1T1...). I've just implemented the new partition schema in numexpr (T0T0...T1T1..., being the original T0T1T0T1...).

[Numpy-discussion] Drawing circles in a numpy array

2011-01-10 Thread totonixs...@gmail.com
Hi all, I have this problem: Given some point draw a circle centered in this point with radius r. I'm doing that using numpy this way (Snippet code from here [1]): # Create the initial black and white image import numpy as np from scipy import ndimage a = np.zeros((512, 512)).astype(uint8)

Re: [Numpy-discussion] speed of numpy.ndarray compared to Numeric.array

2011-01-10 Thread EMMEL Thomas
Hey back... #~ ~ ~~~ def bruteForceSearch(points, point): minpt = min([(vec2Norm(pt, point), pt, i) for i, pt in enumerate(points)], key=itemgetter(0)) return sqrt(minpt[0]), minpt[1],

Re: [Numpy-discussion] speed of numpy.ndarray compared to Numeric.array

2011-01-10 Thread Pascal
Hi, On 01/10/2011 09:09 AM, EMMEL Thomas wrote: No I didn't, due to the fact that these values are coordinates in 3D (x,y,z). In fact I work with a list/array/tuple of arrays with 10 to 1M of elements or more. What I need to do is to calculate the distance of each of these elements

[Numpy-discussion] indexing of rank-0 structured arrays: why not?

2011-01-10 Thread Nils Becker
Hi, I noticed that I can index into a dtype when I take an element of a rank-1 array but not if I make a rank-0 array directly. This seems inconsistent. A bug? Nils In [76]: np.version.version Out[76]: '1.5.1' In [78]: dt = np.dtype([('x', 'f8'), ('y', 'f8')]) In [80]: a_rank_1 =

Re: [Numpy-discussion] speed of numpy.ndarray compared to Numeric.array

2011-01-10 Thread René Dudfield
Hi, Spatial hashes are the common solution. Another common optimization is using the distance squared for collision detection. Since you do not need the expensive sqrt for this calc. cu. On Mon, Jan 10, 2011 at 3:25 PM, Pascal pascal...@parois.net wrote: Hi, On 01/10/2011 09:09 AM, EMMEL

Re: [Numpy-discussion] numexpr with the new iterator

2011-01-10 Thread Mark Wiebe
On Mon, Jan 10, 2011 at 2:05 AM, Francesc Alted fal...@pytables.org wrote: snip Your patch looks mostly fine to my eyes; good job! Unfortunately, I've been unable to compile your new_iterator branch of NumPy: numpy/core/src/multiarray/multiarraymodule.c:45:33: fatal error:

Re: [Numpy-discussion] indexing of rank-0 structured arrays: why not?

2011-01-10 Thread Robert Kern
On Mon, Jan 10, 2011 at 10:08, Nils Becker n.bec...@amolf.nl wrote: Hi, I noticed that I can index into a dtype when I take an element of a rank-1 array but not if I make a rank-0 array directly. This seems inconsistent. A bug? Not a bug. Since there is no axis, you cannot use integers to

Re: [Numpy-discussion] numexpr with the new iterator

2011-01-10 Thread Francesc Alted
A Monday 10 January 2011 17:54:16 Mark Wiebe escrigué: Apparently, you forgot to add the new_iterator_pywrap.h file. Oops, that's added now. Excellent. It works now. The aligned case should just be a matter of conditionally removing the NPY_ITER_ALIGNED flag in two places. Wow, the

Re: [Numpy-discussion] indexing of rank-0 structured arrays: why not?

2011-01-10 Thread Nils Becker
Robert, your answer does work: after indexing with () I can then further index into the datatype. In [115]: a_rank_0[()][0] Out[115]: 0.0 I guess I just found the fact confusing that a_rank_1[0] and a_rank_0 compare and print equal but behave differently under indexing. More precisely if I do

Re: [Numpy-discussion] numexpr with the new iterator

2011-01-10 Thread Mark Wiebe
On Mon, Jan 10, 2011 at 9:47 AM, Francesc Alted fal...@pytables.org wrote: snip so, the new code is just 5% slower. I suppose that removing the NPY_ITER_ALIGNED flag would give us a bit more performance, but that's great as it is now. How did you do that? Your new_iter branch in NumPy

Re: [Numpy-discussion] indexing of rank-0 structured arrays: why not?

2011-01-10 Thread Robert Kern
On Mon, Jan 10, 2011 at 12:15, Nils Becker n.bec...@amolf.nl wrote: Robert, your answer does work: after indexing with () I can then further index into the datatype. In [115]: a_rank_0[()][0] Out[115]: 0.0 I guess I just found the fact confusing that a_rank_1[0] and a_rank_0 compare and

Re: [Numpy-discussion] numexpr with the new iterator

2011-01-10 Thread Mark Wiebe
I'm a bit curious why the jump from 1 to 2 threads is scaling so poorly. Your timings have improvement factors of 1.85, 1.68, 1.64, and 1.79. Since the computation is trivial data parallelism, and I believe it's still pretty far off the memory bandwidth limit, I would expect a speedup of 1.95 or

Re: [Numpy-discussion] numexpr with the new iterator

2011-01-10 Thread Mark Wiebe
On Mon, Jan 10, 2011 at 11:35 AM, Mark Wiebe mwwi...@gmail.com wrote: I'm a bit curious why the jump from 1 to 2 threads is scaling so poorly. Your timings have improvement factors of 1.85, 1.68, 1.64, and 1.79. Since the computation is trivial data parallelism, and I believe it's still