Re: [Numpy-discussion] Slicing slower than matrix multiplication?

2009-12-15 Thread Jasper van de Gronde
Charles R Harris wrote: > Sort of, it's actually (Xi.T*S).T, now that I think of it... I'll see if > that is any faster. And if there is a neater way of doing it I'd love to > hear about it. > > Xi*S[:,newaxis] Thanks! (Obviously doesn't matter much in terms of performance, as it's o

Re: [Numpy-discussion] Slicing slower than matrix multiplication?

2009-12-14 Thread Jasper van de Gronde
Bruce Southey wrote: >> So far this is the fastest code I've got: >> >> import numpy as np >> >> nmax = 100 >> >> def minover(Xi,S): >> P,N = Xi.shape >> SXi = Xi.copy() >> for i in xrange(0,P): >>

Re: [Numpy-discussion] Slicing slower than matrix multiplication?

2009-12-14 Thread Jasper van de Gronde
Francesc Alted wrote: > A Monday 14 December 2009 17:09:13 Francesc Alted escrigué: >> The things seems to be worst than 1.6x times slower for numpy, as matlab >> orders arrays by column, while numpy order is by row. So, if we want to >> compare pears with pears: >> >> For Python 600x200: >>Ad

Re: [Numpy-discussion] Slicing slower than matrix multiplication?

2009-12-13 Thread Jasper van de Gronde
Bruce Southey wrote: > Really I would suggest asking the list for the real problem because it > is often amazing what solutions have been given. So far this is the fastest code I've got: import numpy as np nmax = 100 def mi

Re: [Numpy-discussion] Slicing slower than matrix multiplication?

2009-12-12 Thread Jasper van de Gronde
Francesc Alted wrote: > ... > Yeah, I think taking slices here is taking quite a lot of time: > > In [58]: timeit E + Xi2[P/2,:] > 10 loops, best of 3: 3.95 µs per loop > > In [59]: timeit E + Xi2[P/2] > 10 loops, best of 3: 2.17 µs per loop > > don't know why the additional ',:' in the

Re: [Numpy-discussion] Slicing slower than matrix multiplication?

2009-12-11 Thread Jasper van de Gronde
Dag Sverre Seljebotn wrote: > Jasper van de Gronde wrote: >> I've attached a test file which shows the problem. It also tries adding >> columns instead of rows (in case the memory layout is playing tricks), >> but this seems to make no difference. This is the output I

[Numpy-discussion] Slicing slower than matrix multiplication?

2009-12-11 Thread Jasper van de Gronde
(Resending without attachment as I don't think my previous message arrived.) I just started using numpy and am very, very pleased with the functionality and cleanness so far. However, I tried what I though would be a simple optimization and found that the opposite was true. Specifically, I had a l