Re: [Numpy-discussion] numpy arrays, data allocation and SIMD alignement

2007-08-08 Thread David Cournapeau
Charles R Harris wrote: > Anne, > > On 8/8/07, *Anne Archibald* <[EMAIL PROTECTED] > > wrote: > > On 08/08/2007, Charles R Harris <[EMAIL PROTECTED] > > wrote: > > > > > > On 8/8/07, Anne Archibald <[EMAIL PROTECTED] >

[Numpy-discussion] fromfunction question

2007-08-08 Thread john saponara
Thinking I could use fromfunction to generate the x,y,z coordinates of a 3D surface, I instead got separate arrays of x, y, and z coordinates (as I should have expected) and needed to use a nested listcomp to produce the unified array of 3D points: x,y,z=fromfunction( lambda i,j: (xfun(i,j),yfu

Re: [Numpy-discussion] vectorized function inside a class

2007-08-08 Thread Anne Archibald
On 08/08/2007, mark <[EMAIL PROTECTED]> wrote: > Thanks for the ideas to circumvent vectorization. > But the real function I need to vectorize is quite a bit more > complicated. > So I would really like to use vectorize. > Are there any reasons against vectorization? Is it slow? > The way Tim sugge

Re: [Numpy-discussion] vectorized function inside a class

2007-08-08 Thread mark
Thanks for the ideas to circumvent vectorization. But the real function I need to vectorize is quite a bit more complicated. So I would really like to use vectorize. Are there any reasons against vectorization? Is it slow? The way Tim suggests I expect to be slow as there are two functions calls. T

Re: [Numpy-discussion] numpy arrays, data allocation and SIMD alignement

2007-08-08 Thread Charles R Harris
On 8/8/07, Matthieu Brucher <[EMAIL PROTECTED]> wrote: > > My 64 bit linux on Intel aligns arrays, whatever the data type, on 16 byte > > boundaries. It might be interesting to see what happens with the Intel and > > MSVC comipilers, but I expect similar results. > > > > According to the doc on the

Re: [Numpy-discussion] numpy arrays, data allocation and SIMD alignement

2007-08-08 Thread Matthieu Brucher
> > My 64 bit linux on Intel aligns arrays, whatever the data type, on 16 byte > boundaries. It might be interesting to see what happens with the Intel and > MSVC comipilers, but I expect similar results. > According to the doc on the msdn, the data should be 16-bits aligned. Matthieu ___

Re: [Numpy-discussion] numpy arrays, data allocation and SIMD alignement

2007-08-08 Thread Charles R Harris
Anne, On 8/8/07, Anne Archibald <[EMAIL PROTECTED]> wrote: > > On 08/08/2007, Charles R Harris <[EMAIL PROTECTED]> wrote: > > > > > > On 8/8/07, Anne Archibald <[EMAIL PROTECTED]> wrote: > > > Oh. Well, it's not *terrible*; it gets you an aligned array. But you > > > have to allocate the original

Re: [Numpy-discussion] numpy arrays, data allocation and SIMD alignement

2007-08-08 Thread Anne Archibald
On 08/08/2007, Charles R Harris <[EMAIL PROTECTED]> wrote: > > > On 8/8/07, Anne Archibald <[EMAIL PROTECTED]> wrote: > > Oh. Well, it's not *terrible*; it gets you an aligned array. But you > > have to allocate the original array as a 1D byte array (to allow for > > arbitrary realignments) and the

[Numpy-discussion] Count the occurrence of a certain integer in a list of integers

2007-08-08 Thread Mark.Miller
A late entry, but here's something that gets you an array of counts for each unique integer: >>> data = numpy.array([9, 6, 9, 6, 7, 9, 9, 10, 7, 9, 9, 6, 7, 9, 8, 8, 11, 9, 6, 7, 10, 9, 7, 9, 7, 8, 9, 8, 7, 9]) >>> unique=numpy.unique(data) >>> unique array([ 6, 7, 8, 9, 10, 11]) >>> hist

Re: [Numpy-discussion] vectorized function inside a class

2007-08-08 Thread Stefan van der Walt
On Wed, Aug 08, 2007 at 08:54:18AM -0700, Timothy Hochberg wrote: > Don't use vectorize? Something like: > > def f(self,y): > return np.where(y > self.x, y, self.x) A one-liner, cool. Benchmarks on some other methods: Method 1: N.where 100 loops, best of 3: 9.32 ms per loop Method 2: N.cl

Re: [Numpy-discussion] numpy arrays, data allocation and SIMD alignement

2007-08-08 Thread Charles R Harris
On 8/8/07, Anne Archibald <[EMAIL PROTECTED]> wrote: > > On 08/08/2007, Stefan van der Walt <[EMAIL PROTECTED]> wrote: > > On Tue, Aug 07, 2007 at 01:33:24AM -0400, Anne Archibald wrote: > > > Well, it can be done in Python: just allocate a too-big ndarray and > > > take a slice that's the right sh

Re: [Numpy-discussion] vectorized function inside a class

2007-08-08 Thread Timothy Hochberg
On 8/8/07, mark <[EMAIL PROTECTED]> wrote: > > I am trying to figure out a way to define a vectorized function inside > a class. > This is what I tried: > > class test: > def __init__(self): > self.x = 3.0 > def func(self,y): > rv = self.x >

Re: [Numpy-discussion] vectorized function inside a class

2007-08-08 Thread Stefan van der Walt
Hi Mark On Wed, Aug 08, 2007 at 03:37:09PM -, mark wrote: > I am trying to figure out a way to define a vectorized function inside > a class. > This is what I tried: > > class test: > def __init__(self): > self.x = 3.0 > def func(self,y): > rv = self.x

[Numpy-discussion] vectorized function inside a class

2007-08-08 Thread mark
I am trying to figure out a way to define a vectorized function inside a class. This is what I tried: class test: def __init__(self): self.x = 3.0 def func(self,y): rv = self.x if y > self.x: rv = y return rv f

Re: [Numpy-discussion] numpy arrays, data allocation and SIMD alignement

2007-08-08 Thread Anne Archibald
On 08/08/2007, Stefan van der Walt <[EMAIL PROTECTED]> wrote: > On Tue, Aug 07, 2007 at 01:33:24AM -0400, Anne Archibald wrote: > > Well, it can be done in Python: just allocate a too-big ndarray and > > take a slice that's the right shape and has the right alignment. But > > this sucks. > > Could

Re: [Numpy-discussion] simple slicing question

2007-08-08 Thread mark
Life is so simple. Thanks Keith, Mark On Aug 8, 12:53 pm, "Keith Goodman" <[EMAIL PROTECTED]> wrote: > On 8/8/07, mark <[EMAIL PROTECTED]> wrote: > > > But what if I want to multiply every value between -5 and +5 by 100. > > This does NOT work: > > > d[ d>-5 and d<5 ] *= 100 > > d[(d>-5) & (d<5)]

Re: [Numpy-discussion] simple slicing question

2007-08-08 Thread Keith Goodman
On 8/8/07, mark <[EMAIL PROTECTED]> wrote: > But what if I want to multiply every value between -5 and +5 by 100. > This does NOT work: > > d[ d>-5 and d<5 ] *= 100 d[(d>-5) & (d<5)] *= 100 ___ Numpy-discussion mailing list Numpy-discussion@scipy.org ht

[Numpy-discussion] simple slicing question

2007-08-08 Thread mark
Consider the array d: d = linspace( -10, 10, 10 ) If I want to multiply every value above -5 by 100 I can do d[ d>-5 ] *= 100 But what if I want to multiply every value between -5 and +5 by 100. This does NOT work: d[ d>-5 and d<5 ] *= 100 Any ideas? Thanks, Mark ___

Re: [Numpy-discussion] numpy arrays, data allocation and SIMD alignement

2007-08-08 Thread Stefan van der Walt
On Tue, Aug 07, 2007 at 01:33:24AM -0400, Anne Archibald wrote: > Well, it can be done in Python: just allocate a too-big ndarray and > take a slice that's the right shape and has the right alignment. But > this sucks. Could you explain to me why is this such a bad idea? Stéfan __

Re: [Numpy-discussion] numpy installation problem

2007-08-08 Thread lorenzo bolla
sorry for the silly question: have you done "python setup.py install" from the numpy src directory, after untarring? then cd out from the src directory and try to import numpy from python. L. On 7/31/07, kingshuk ghosh <[EMAIL PROTECTED]> wrote: > > Hi, > I downloaded numpy1.0.3-2.tar and unzippe