Re: [Numpy-discussion] Vectorizing computation

2015-02-13 Thread Francesc Alted
2015-02-13 13:25 GMT+01:00 Julian Taylor : > On 02/13/2015 01:03 PM, Francesc Alted wrote: > > 2015-02-13 12:51 GMT+01:00 Julian Taylor > >: > > > > On 02/13/2015 11:51 AM, Francesc Alted wrote: > > > Hi, > > > > > > I would like to vectorize

Re: [Numpy-discussion] Vectorizing computation

2015-02-13 Thread Julian Taylor
On 02/13/2015 01:03 PM, Francesc Alted wrote: > 2015-02-13 12:51 GMT+01:00 Julian Taylor >: > > On 02/13/2015 11:51 AM, Francesc Alted wrote: > > Hi, > > > > I would like to vectorize the next computation: > > > > nx, ny, nz = 720, 180

Re: [Numpy-discussion] Vectorizing computation

2015-02-13 Thread Francesc Alted
2015-02-13 12:51 GMT+01:00 Julian Taylor : > On 02/13/2015 11:51 AM, Francesc Alted wrote: > > 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(outheigh

Re: [Numpy-discussion] Vectorizing computation

2015-02-13 Thread Julian Taylor
On 02/13/2015 11:51 AM, Francesc Alted wrote: > 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 i

[Numpy-discussion] Vectorizing computation

2015-02-13 Thread Francesc Alted
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, :,

Re: [Numpy-discussion] vectorizing recursive sequences

2013-10-26 Thread Bago
This behavior seems to depend on the order in which elements of the arrays are processes. That seems like a dangerous thing to rely on, the main reason I can thing of that someone would want to change the loop order is to implement parallel ufuncs. Bago On Fri, Oct 25, 2013 at 12:32 PM, Jaime F

Re: [Numpy-discussion] vectorizing recursive sequences

2013-10-25 Thread Pierre Haessig
"Jaime Fernández del Río" a écrit : >I recently came up with a way of vectorizing some recursive sequence >calculations. While it works, I am afraid it is relying on >implementation >details potentially subject to change. The basic idea is illustrated by >this function, calculating the first n it

[Numpy-discussion] vectorizing recursive sequences

2013-10-25 Thread Jaime Fernández del Río
I recently came up with a way of vectorizing some recursive sequence calculations. While it works, I am afraid it is relying on implementation details potentially subject to change. The basic idea is illustrated by this function, calculating the first n items of the Fibonacci sequence: def fibonac

Re: [Numpy-discussion] Vectorizing!!!!

2011-11-19 Thread Eric Carlson
I'm not sure if I am addressing your question on vectorizing directly, but consider the following code, which does (maybe?) what your asking. import scipy from numpy import reshape,ones, zeros, arange, array A=reshape(arange(100),[10,10]) nr,nc=A.shape B=zeros(A.shape) #initialize array #calcu

[Numpy-discussion] Vectorizing!!!!

2011-11-19 Thread Solimyr
Hi all!!!I'm pretty new here!! I'm just use my free time to learn something more about pythonI just discovered a new word named 'Vectorizing' I'm going to explain my question...I have a matrix (no care about the size) and I want made some mathematical operations like mean,standard deviatio

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread josef . pktd
On Fri, Jun 5, 2009 at 5:59 PM, Brent Pedersen wrote: > On Fri, Jun 5, 2009 at 2:01 PM, Keith Goodman wrote: >> On Fri, Jun 5, 2009 at 1:22 PM, Brent Pedersen wrote: >>> On Fri, Jun 5, 2009 at 1:05 PM, Keith Goodman wrote: On Fri, Jun 5, 2009 at 1:01 PM, Keith Goodman wrote: > On Fri, J

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread Brent Pedersen
On Fri, Jun 5, 2009 at 2:01 PM, Keith Goodman wrote: > On Fri, Jun 5, 2009 at 1:22 PM, Brent Pedersen wrote: >> On Fri, Jun 5, 2009 at 1:05 PM, Keith Goodman wrote: >>> On Fri, Jun 5, 2009 at 1:01 PM, Keith Goodman wrote: On Fri, Jun 5, 2009 at 12:53 PM,   wrote: > On Fri, Jun 5, 2009 at

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread Keith Goodman
On Fri, Jun 5, 2009 at 1:22 PM, Brent Pedersen wrote: > On Fri, Jun 5, 2009 at 1:05 PM, Keith Goodman wrote: >> On Fri, Jun 5, 2009 at 1:01 PM, Keith Goodman wrote: >>> On Fri, Jun 5, 2009 at 12:53 PM,   wrote: On Fri, Jun 5, 2009 at 2:07 PM, Brian Blais wrote: > Hello, > I have a v

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread josef . pktd
On Fri, Jun 5, 2009 at 4:35 PM, Keith Goodman wrote: > On Fri, Jun 5, 2009 at 1:31 PM,   wrote: >> On Fri, Jun 5, 2009 at 4:27 PM, Keith Goodman wrote: >>> On Fri, Jun 5, 2009 at 1:22 PM, Brent Pedersen wrote: On Fri, Jun 5, 2009 at 1:05 PM, Keith Goodman wrote: > On Fri, Jun 5, 2009 at

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread Keith Goodman
On Fri, Jun 5, 2009 at 1:31 PM, wrote: > On Fri, Jun 5, 2009 at 4:27 PM, Keith Goodman wrote: >> On Fri, Jun 5, 2009 at 1:22 PM, Brent Pedersen wrote: >>> On Fri, Jun 5, 2009 at 1:05 PM, Keith Goodman wrote: On Fri, Jun 5, 2009 at 1:01 PM, Keith Goodman wrote: > On Fri, Jun 5, 2009 at

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread Brent Pedersen
On Fri, Jun 5, 2009 at 1:27 PM, Keith Goodman wrote: > On Fri, Jun 5, 2009 at 1:22 PM, Brent Pedersen wrote: >> On Fri, Jun 5, 2009 at 1:05 PM, Keith Goodman wrote: >>> On Fri, Jun 5, 2009 at 1:01 PM, Keith Goodman wrote: On Fri, Jun 5, 2009 at 12:53 PM,   wrote: > On Fri, Jun 5, 2009 at

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread josef . pktd
On Fri, Jun 5, 2009 at 4:27 PM, Keith Goodman wrote: > On Fri, Jun 5, 2009 at 1:22 PM, Brent Pedersen wrote: >> On Fri, Jun 5, 2009 at 1:05 PM, Keith Goodman wrote: >>> On Fri, Jun 5, 2009 at 1:01 PM, Keith Goodman wrote: On Fri, Jun 5, 2009 at 12:53 PM,   wrote: > On Fri, Jun 5, 2009 a

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread Keith Goodman
On Fri, Jun 5, 2009 at 1:22 PM, Brent Pedersen wrote: > On Fri, Jun 5, 2009 at 1:05 PM, Keith Goodman wrote: >> On Fri, Jun 5, 2009 at 1:01 PM, Keith Goodman wrote: >>> On Fri, Jun 5, 2009 at 12:53 PM,   wrote: On Fri, Jun 5, 2009 at 2:07 PM, Brian Blais wrote: > Hello, > I have a v

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread Brent Pedersen
On Fri, Jun 5, 2009 at 1:05 PM, Keith Goodman wrote: > On Fri, Jun 5, 2009 at 1:01 PM, Keith Goodman wrote: >> On Fri, Jun 5, 2009 at 12:53 PM,   wrote: >>> On Fri, Jun 5, 2009 at 2:07 PM, Brian Blais wrote: Hello, I have a vectorizing problem that I don't see an obvious way to solve.  

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread Keith Goodman
On Fri, Jun 5, 2009 at 1:01 PM, Keith Goodman wrote: > On Fri, Jun 5, 2009 at 12:53 PM,   wrote: >> On Fri, Jun 5, 2009 at 2:07 PM, Brian Blais wrote: >>> Hello, >>> I have a vectorizing problem that I don't see an obvious way to solve.  What >>> I have is a vector like: >>> obs=array([1,2,3,4,3,

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread josef . pktd
On Fri, Jun 5, 2009 at 3:53 PM, wrote: > On Fri, Jun 5, 2009 at 2:07 PM, Brian Blais wrote: >> Hello, >> I have a vectorizing problem that I don't see an obvious way to solve.  What >> I have is a vector like: >> obs=array([1,2,3,4,3,2,1,2,1,2,1,5,4,3,2]) >> and a matrix >> T=zeros((6,6)) >> and

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread Keith Goodman
On Fri, Jun 5, 2009 at 12:53 PM, wrote: > On Fri, Jun 5, 2009 at 2:07 PM, Brian Blais wrote: >> Hello, >> I have a vectorizing problem that I don't see an obvious way to solve.  What >> I have is a vector like: >> obs=array([1,2,3,4,3,2,1,2,1,2,1,5,4,3,2]) >> and a matrix >> T=zeros((6,6)) >> an

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread josef . pktd
On Fri, Jun 5, 2009 at 2:07 PM, Brian Blais wrote: > Hello, > I have a vectorizing problem that I don't see an obvious way to solve.  What > I have is a vector like: > obs=array([1,2,3,4,3,2,1,2,1,2,1,5,4,3,2]) > and a matrix > T=zeros((6,6)) > and what I want in T is a count of all of the transit

Re: [Numpy-discussion] vectorizing

2009-06-05 Thread Keith Goodman
On Fri, Jun 5, 2009 at 11:07 AM, Brian Blais wrote: > Hello, > I have a vectorizing problem that I don't see an obvious way to solve.  What > I have is a vector like: > obs=array([1,2,3,4,3,2,1,2,1,2,1,5,4,3,2]) > and a matrix > T=zeros((6,6)) > and what I want in T is a count of all of the transi

[Numpy-discussion] vectorizing

2009-06-05 Thread Brian Blais
Hello, I have a vectorizing problem that I don't see an obvious way to solve. What I have is a vector like: obs=array([1,2,3,4,3,2,1,2,1,2,1,5,4,3,2]) and a matrix T=zeros((6,6)) and what I want in T is a count of all of the transitions in obs, e.g. T[1,2]=3 because the sequence 1-2 hap

Re: [Numpy-discussion] Vectorizing array updates

2009-04-29 Thread Anne Archibald
2009/4/29 Dan Goodman : > Robert Kern wrote: >> On Wed, Apr 29, 2009 at 16:19, Dan Goodman wrote: >>> Robert Kern wrote: On Wed, Apr 29, 2009 at 08:03, Daniel Yarlett wrote: > As you can see, Current is different in the two cases. Any ideas how I > can recreate the behavio

Re: [Numpy-discussion] Vectorizing array updates

2009-04-29 Thread Dan Goodman
Robert Kern wrote: > On Wed, Apr 29, 2009 at 16:19, Dan Goodman wrote: >> Robert Kern wrote: >>> On Wed, Apr 29, 2009 at 08:03, Daniel Yarlett >>> wrote: >>> As you can see, Current is different in the two cases. Any ideas how I can recreate the behavior of the iterative process in a m

Re: [Numpy-discussion] Vectorizing array updates

2009-04-29 Thread Robert Kern
On Wed, Apr 29, 2009 at 16:19, Dan Goodman wrote: > Robert Kern wrote: >> On Wed, Apr 29, 2009 at 08:03, Daniel Yarlett >> wrote: >> >>> As you can see, Current is different in the two cases. Any ideas how I >>> can recreate the behavior of the iterative process in a more numpy- >>> friendly, ve

Re: [Numpy-discussion] Vectorizing array updates

2009-04-29 Thread Dan Goodman
Robert Kern wrote: > On Wed, Apr 29, 2009 at 08:03, Daniel Yarlett > wrote: > >> As you can see, Current is different in the two cases. Any ideas how I >> can recreate the behavior of the iterative process in a more numpy- >> friendly, vectorized (and hopefully quicker) way? > > Use bincount().

Re: [Numpy-discussion] Vectorizing array updates

2009-04-29 Thread Robert Kern
On Wed, Apr 29, 2009 at 08:03, Daniel Yarlett wrote: > As you can see, Current is different in the two cases. Any ideas how I > can recreate the behavior of the iterative process in a more numpy- > friendly, vectorized (and hopefully quicker) way? Use bincount(). > And possibly also > about why

Re: [Numpy-discussion] Vectorizing array updates

2009-04-29 Thread Dan Goodman
> As you can see, Current is different in the two cases. Any ideas how I > can recreate the behavior of the iterative process in a more numpy- > friendly, vectorized (and hopefully quicker) way? And possibly also > about why my intuitions concerning the semantics of the vectorized > code are

[Numpy-discussion] Vectorizing array updates

2009-04-29 Thread Daniel Yarlett
Hi All, I'm coding an iterative algorithm which needs to update a results array on each iteration. I have several (one-dimensional) arrays, and currently I have the following non-vectorized code which gets called at the end of each iteration (Inds, Current, and Update are all one- dimension

Re: [Numpy-discussion] Vectorizing "dot" on the two last axis

2008-10-11 Thread Gael Varoquaux
On Fri, Oct 10, 2008 at 09:03:14AM -0400, Anne Archibald wrote: > I am pretty sure that, unfortunately, there is no way to vectorize > this without an intermediate array substantially larger than either > the inputs or the outputs. OK, this is what I had found. > From a computational point of vie

Re: [Numpy-discussion] Vectorizing "dot" on the two last axis

2008-10-10 Thread Anne Archibald
2008/10/10 Gael Varoquaux <[EMAIL PROTECTED]>: > I have been unable to vectorize the following operation:: > >window_size = 10 >nb_windows = 819 >nb_clusters = 501 >restricted_series = np.random.random(size=(window_size, nb_clusters, >

[Numpy-discussion] Vectorizing "dot" on the two last axis

2008-10-10 Thread Gael Varoquaux
Hi list, I have been unable to vectorize the following operation:: window_size = 10 nb_windows = 819 nb_clusters = 501 restricted_series = np.random.random(size=(window_size, nb_clusters, nb_windows)) this_cov = np.zeros((nb

Re: [Numpy-discussion] Vectorizing a function

2008-01-30 Thread LB
Thank you Gael, I think this could work for my case. It will be a bit tricky, since calc_0d is already a closure in which I've defined a function : the parameters x and y are to main parameters of an ODE. So calc_0d define a function, integrate it sing scipy.integrate.odeint and returns some chara

Re: [Numpy-discussion] Vectorizing a function

2008-01-30 Thread Charles R Harris
On Jan 30, 2008 10:18 AM, Timothy Hochberg <[EMAIL PROTECTED]> wrote: > > > On Jan 30, 2008 10:10 AM, Charles R Harris <[EMAIL PROTECTED]> > wrote: > > [SNIP] > > > > > > IIRC, the way to do closures in Python is something like > > > > In [5]: def factory(x) : > >...: def f() : > >...:

Re: [Numpy-discussion] Vectorizing a function

2008-01-30 Thread Charles R Harris
On Jan 30, 2008 10:10 AM, Charles R Harris <[EMAIL PROTECTED]> wrote: > > > On Jan 30, 2008 2:22 AM, Gael Varoquaux <[EMAIL PROTECTED]> > wrote: > > > On Wed, Jan 30, 2008 at 12:49:44AM -0800, LB wrote: > > > My problem is that the complexe calculations made in calc_0d use some > > > parameters, w

Re: [Numpy-discussion] Vectorizing a function

2008-01-30 Thread Timothy Hochberg
On Jan 30, 2008 10:10 AM, Charles R Harris <[EMAIL PROTECTED]> wrote: [SNIP] > > IIRC, the way to do closures in Python is something like > > In [5]: def factory(x) : >...: def f() : >...: print x >...: f.x = x >...: return f >...: > > In [6]: f = factory(

Re: [Numpy-discussion] Vectorizing a function

2008-01-30 Thread Charles R Harris
On Jan 30, 2008 2:22 AM, Gael Varoquaux <[EMAIL PROTECTED]> wrote: > On Wed, Jan 30, 2008 at 12:49:44AM -0800, LB wrote: > > My problem is that the complexe calculations made in calc_0d use some > > parameters, which are currently defined at the head of my python file. > > This is not very nice an

Re: [Numpy-discussion] Vectorizing a function

2008-01-30 Thread Anne Archibald
On 30/01/2008, Scott Ransom <[EMAIL PROTECTED]> wrote: > That works fine with arrays, scalars, or array/scalar mixes in the > calling. I do understand that more complicated functions might > require vectorize(), however, I wonder if sometimes it is used > when it doesn't need to be? It certainly

Re: [Numpy-discussion] Vectorizing a function

2008-01-30 Thread Scott Ransom
On a side note, given that I've seen quite a few posts about vectorize() over the past several months... I've written hundreds or thousands of functions that are intended to work with numeric/numpy arrays and/or scalars and I've _never_ (not once!) found a need for the vectorize function. Python'

Re: [Numpy-discussion] Vectorizing a function

2008-01-30 Thread Gael Varoquaux
On Wed, Jan 30, 2008 at 12:49:44AM -0800, LB wrote: > My problem is that the complexe calculations made in calc_0d use some > parameters, which are currently defined at the head of my python file. > This is not very nice and I can't define a module containing theses > two functions and call them wi

Re: [Numpy-discussion] Vectorizing a function

2008-01-30 Thread YW
Try use a closure. On Jan 30, 12:49 am, LB <[EMAIL PROTECTED]> wrote: >    Hi, > > I've got some questions on the numpy.vectorize  function. > Currently, i'm doing this kind of work : > > [ code] > def calc_0d(x, y): >     """ make complexe calculation using two scalars x and y """ >     [ ... ] >

[Numpy-discussion] Vectorizing a function

2008-01-30 Thread LB
Hi, I've got some questions on the numpy.vectorize function. Currently, i'm doing this kind of work : [ code] def calc_0d(x, y): """ make complexe calculation using two scalars x and y """ [ ... ] return res1, res2, res 3 # vectorize the function calc = vectorize(calc_0d) res1,

Re: [Numpy-discussion] vectorizing loops

2007-11-02 Thread Francesc Altet
A Thursday 01 November 2007, Timothy Hochberg escrigué: > On Nov 1, 2007 7:14 AM, David M. Cooke <[EMAIL PROTECTED]> > > Another issue is that numexpr is still in the scipy sandbox, so > > only those who enable it will use it (or use it through PyTables). > > One problem with moving it out is that

Re: [Numpy-discussion] vectorizing loops

2007-11-02 Thread Francesc Altet
A Thursday 01 November 2007, David M. Cooke escrigué: > > At any rate, we would be glad if you would like to integrate our > > patches > > in the main numexpr, as there is not much sense to have different > > implementations of numexpr (most specially when it seems that there > > are > > not much u

Re: [Numpy-discussion] vectorizing loops

2007-11-01 Thread Timothy Hochberg
On Nov 1, 2007 7:14 AM, David M. Cooke <[EMAIL PROTECTED]> wrote: > On Nov 1, 2007, at 08:56 , Francesc Altet wrote: > > > A Wednesday 31 October 2007, Timothy Hochberg escrigué: > >> On Oct 31, 2007 3:18 AM, Francesc Altet <[EMAIL PROTECTED]> wrote: > >> > >> [SNIP] > >> > >>> Incidentally, all t

Re: [Numpy-discussion] vectorizing loops

2007-11-01 Thread David M. Cooke
On Nov 1, 2007, at 08:56 , Francesc Altet wrote: > A Wednesday 31 October 2007, Timothy Hochberg escrigué: >> On Oct 31, 2007 3:18 AM, Francesc Altet <[EMAIL PROTECTED]> wrote: >> >> [SNIP] >> >>> Incidentally, all the improvements of the PyTables flavor of >>> numexpr have been reported to the or

Re: [Numpy-discussion] vectorizing loops

2007-11-01 Thread Francesc Altet
A Wednesday 31 October 2007, Timothy Hochberg escrigué: > On Oct 31, 2007 3:18 AM, Francesc Altet <[EMAIL PROTECTED]> wrote: > > [SNIP] > > > Incidentally, all the improvements of the PyTables flavor of > > numexpr have been reported to the original authors, but, for the > > sake of keeping numexpr

Re: [Numpy-discussion] vectorizing loops

2007-10-31 Thread Timothy Hochberg
On Oct 31, 2007 3:18 AM, Francesc Altet <[EMAIL PROTECTED]> wrote: [SNIP] > Incidentally, all the improvements of the PyTables flavor of numexpr > have been reported to the original authors, but, for the sake of > keeping numexpr simple, they decided to implement only some of them. > However, peo

Re: [Numpy-discussion] vectorizing loops

2007-10-31 Thread Francesc Altet
A Wednesday 31 October 2007, Mathew Yeates escrigué: [...] > I also took a look at NumExpr. While it wasn't something I needed for > vectorizing, it still looks very interesting. What kinds of > performance improvements would be expected using this? Well, for some speedup figures you can always ch

Re: [Numpy-discussion] vectorizing loops

2007-10-30 Thread Mathew Yeates
Thanks all for your suggestions. I see it brought up a lot of interesting asides. But my loop was simple enough that I was able to figure it out. I also took a look at NumExpr. While it wasn't something I needed for vectorizing, it still looks very interesting. What kinds of performance improv

Re: [Numpy-discussion] vectorizing loops

2007-10-29 Thread David Cournapeau
Timothy Hochberg wrote: > > > On 10/29/07, *Christopher Barker* <[EMAIL PROTECTED] > > wrote: > > >> (incidently, the kind of things 'we' are doing seem like the most > > simple things to JIT). > > Wouldn't a numpy-aware psyco be cool then? > > Oh well, I'

Re: [Numpy-discussion] vectorizing loops

2007-10-29 Thread Timothy Hochberg
On 10/29/07, Christopher Barker <[EMAIL PROTECTED]> wrote: > > >> (incidently, the kind of things 'we' are doing seem like the most > > simple things to JIT). > > Wouldn't a numpy-aware psyco be cool then? > > Oh well, I'm not going to write it! > > (though as I think about it, for the special case

Re: [Numpy-discussion] vectorizing loops

2007-10-29 Thread Christopher Barker
>> (incidently, the kind of things 'we' are doing seem like the most > simple things to JIT). Wouldn't a numpy-aware psyco be cool then? Oh well, I'm not going to write it! (though as I think about it, for the special case of a contiguous array, it would be awfully similar to an array.array --

Re: [Numpy-discussion] vectorizing loops

2007-10-28 Thread David Cournapeau
Sebastian Haase wrote: > On 10/26/07, David Cournapeau <[EMAIL PROTECTED]> wrote: > >> P.S: IMHO, this is one of the main limitation of numpy (or any language >> using arrays for speed; and this is really difficult to optimize: you >> need compilation, JIT or similar to solve those efficiently).

Re: [Numpy-discussion] vectorizing loops

2007-10-26 Thread Charles R Harris
Hi, On 10/26/07, Timothy Hochberg <[EMAIL PROTECTED]> wrote: > > > On 10/26/07, Sebastian Haase <[EMAIL PROTECTED]> wrote: > > On 10/26/07, David Cournapeau <[EMAIL PROTECTED]> wrote: > > > P.S: IMHO, this is one of the main limitation of numpy (or any language > > > using arrays for speed; and th

Re: [Numpy-discussion] vectorizing loops

2007-10-26 Thread Timothy Hochberg
On 10/26/07, Sebastian Haase <[EMAIL PROTECTED]> wrote: > > On 10/26/07, David Cournapeau <[EMAIL PROTECTED]> wrote: > > P.S: IMHO, this is one of the main limitation of numpy (or any language > > using arrays for speed; and this is really difficult to optimize: you > > need compilation, JIT or sim

Re: [Numpy-discussion] vectorizing loops

2007-10-26 Thread Sebastian Haase
On 10/26/07, David Cournapeau <[EMAIL PROTECTED]> wrote: > P.S: IMHO, this is one of the main limitation of numpy (or any language > using arrays for speed; and this is really difficult to optimize: you > need compilation, JIT or similar to solve those efficiently). This is where the scipy - sandb

Re: [Numpy-discussion] vectorizing loops

2007-10-26 Thread Gael Varoquaux
On Fri, Oct 26, 2007 at 01:56:26AM -0500, Robert Kern wrote: > Gael Varoquaux wrote: > > On Thu, Oct 25, 2007 at 04:16:06PM -0700, Mathew Yeates wrote: > >> Anybody know of any tricks for handling something like > >> z[0]=1.0 > >> for i in range(100): > >> out[i]=func1(z[i]) > >> z[i+1]=fu

Re: [Numpy-discussion] vectorizing loops

2007-10-25 Thread Robert Kern
Gael Varoquaux wrote: > On Thu, Oct 25, 2007 at 04:16:06PM -0700, Mathew Yeates wrote: >> Anybody know of any tricks for handling something like > >> z[0]=1.0 >> for i in range(100): >> out[i]=func1(z[i]) >> z[i+1]=func2(out[i]) > > Something like: > > z[0] = 1. > out = func1(z) > z[1:]

Re: [Numpy-discussion] vectorizing loops

2007-10-25 Thread David Cournapeau
Gael Varoquaux wrote: > On Thu, Oct 25, 2007 at 04:16:06PM -0700, Mathew Yeates wrote: >> Anybody know of any tricks for handling something like > >> z[0]=1.0 >> for i in range(100): >> out[i]=func1(z[i]) >> z[i+1]=func2(out[i]) > > Something like: > > z[0] = 1. > out = func1(z) > z[1:] = f

Re: [Numpy-discussion] vectorizing loops

2007-10-25 Thread Gael Varoquaux
On Thu, Oct 25, 2007 at 04:16:06PM -0700, Mathew Yeates wrote: > Anybody know of any tricks for handling something like > z[0]=1.0 > for i in range(100): > out[i]=func1(z[i]) > z[i+1]=func2(out[i]) Something like: z[0] = 1. out = func1(z) z[1:] = func2(out[:-1]) HTH, Gaël _

[Numpy-discussion] vectorizing loops

2007-10-25 Thread Mathew Yeates
Anybody know of any tricks for handling something like z[0]=1.0 for i in range(100): out[i]=func1(z[i]) z[i+1]=func2(out[i]) ?? ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-di

Re: [Numpy-discussion] Vectorizing a class method

2007-02-14 Thread Wojciech Śmigaj
Tom Denniston wrote: > I don't know if this helps but you could use where to do the dispatch > between the two different formulas. Yes, that's a good idea. Thanks! Wojciech Smigaj ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://proje

Re: [Numpy-discussion] Vectorizing a class method

2007-02-14 Thread Wojciech Śmigaj
Anne Archibald wrote: > The appropriate spelling for this, in modern pythons, is > > class X: > @vectorize > def func(self, n): > return 2*n > > Not that it makes it work any better. > > There's no reason vectorize couldn't be made to do the Right Thing > when handed (bound and unbound)

Re: [Numpy-discussion] Vectorizing a class method

2007-02-14 Thread Anne Archibald
On 14/02/07, Wojciech Śmigaj <[EMAIL PROTECTED]> wrote: > Timothy Hochberg wrote: > > On 2/14/07, *Wojciech Śmigaj* <[EMAIL PROTECTED] > > > wrote: > >> I have a question about the vectorize function. I'd like to use it to > >> create a vectorized version of a clas

Re: [Numpy-discussion] Vectorizing a class method

2007-02-14 Thread Tom Denniston
I don't know if this helps but you could use where to do the dispatch between the two different formulas. I don't know the answer to your original question however. On 2/14/07, Wojciech Śmigaj <[EMAIL PROTECTED]> wrote: > Timothy Hochberg wrote: > > On 2/14/07, *Wojciech Śmigaj* <[EMAIL PROTECTED

Re: [Numpy-discussion] Vectorizing a class method

2007-02-14 Thread Wojciech Śmigaj
Timothy Hochberg wrote: > On 2/14/07, *Wojciech Śmigaj* <[EMAIL PROTECTED] > > wrote: >> I have a question about the vectorize function. I'd like to use it to >> create a vectorized version of a class method. I've tried the following >> code: >> >>fro

Re: [Numpy-discussion] Vectorizing a class method

2007-02-14 Thread Timothy Hochberg
On 2/14/07, Wojciech Śmigaj <[EMAIL PROTECTED]> wrote: Hi, I have a question about the vectorize function. I'd like to use it to create a vectorized version of a class method. I've tried the following code: from numpy import * class X: def func(self, n): return 2 * n

[Numpy-discussion] Vectorizing a class method

2007-02-14 Thread Wojciech Śmigaj
Hi, I have a question about the vectorize function. I'd like to use it to create a vectorized version of a class method. I've tried the following code: from numpy import * class X: def func(self, n): return 2 * n # example func = vectorize(func) Now, when I dec