Hi Bevan
Since the number of output elements are unknown, I don't think you can
implement this efficiently using arrays. If your dataset isn't too
large, a for-loop should do the trick. Otherwise, you may have to run
your code through Cython, which optimises for-loops around Python
lists.
thres
Hello,
Sometimes the hardest part of a problem is articulating it. Hopefully I can
describe what I am trying to do - at least enough to get some help.
I am trying to compare values to a threshold and when the values are lower than
the threshold they are added to the value in my set until the thr
John Hunter wrote:
Partly as an excuse to learn cython, and partly because I need to eke
out some extra performance of a neighborhood search, I tried to code
up a brute force neighborhood search in cython around an N-dimensional
point p. I need to incrementally add a point, do a search, add
anot
Partly as an excuse to learn cython, and partly because I need to eke
out some extra performance of a neighborhood search, I tried to code
up a brute force neighborhood search in cython around an N-dimensional
point p. I need to incrementally add a point, do a search, add
another point, do another
On Wed, Jan 07, 2009 at 07:29:41PM +0100, Xavier Gnata wrote:
> Well it is the best pitch for numpy versus matlab I have read so far :)
> (and I 100% agree)
+1. This is an excellent text. IMHO it should be on the wiki somewhere.
Gaël
___
Numpy-discussio
On 7-Jan-09, at 2:26 PM, Sturla Molden wrote:
> Matlab does not have broadcasting. Array shapes must always match.
Not totally true. They introduced a clunky, clunky syntax for it in
version 7, IIRC, called 'bsxfun'.
See http://tinyurl.com/9e7kyt . It's a better solution than indexing
with a
On Wed, Jan 7, 2009 at 10:19, Nicolas ROUX wrote:
> Hi,
>
> I need help ;-)
> I have here a testcase which works much faster in Matlab than Numpy.
>
> The following code takes less than 0.9sec in Matlab, but 21sec in Python.
> Numpy is 24 times slower than Matlab !
> The big trouble I have is a la
On 1/7/2009 7:52 PM, josef.p...@gmail.com wrote:
> But, I think,
> matlab is ahead in parallelization (which I haven't used much)
Not really. There is e.g. nothing like Python's multiprocessing package
in Matlab. Matlab is genrally single-threaded. Python is multi-threaded
but there is a GIL. A
On Wed, Jan 7, 2009 at 1:32 PM, Sturla Molden wrote:
> On 1/7/2009 6:56 PM, Christopher Barker wrote:
>
>>> So for simple loops python looses, but for other things, python wins
>>> by a huge margin.
>>
>> which emphasizes the point that you can't write code the same way in the
>> two languages, th
On 1/7/2009 6:51 PM, Christopher Barker wrote:
> Even with this nifty JIT,
It is not a very nifty JIT. It can transform some simple loops into
vectorized expressions. And it removes the overhead from indexing with
doubles.
But if you are among those that do
n = length(x)
m = 0
for i = 1.0 :
On 1/7/2009 6:56 PM, Christopher Barker wrote:
>> So for simple loops python looses, but for other things, python wins
>> by a huge margin.
>
> which emphasizes the point that you can't write code the same way in the
> two languages, though I'd argue that that code needs refactoring in any
> la
A Wednesday 07 January 2009, Christopher Barker escrigué:
[clip]
> Even with this nifty JIT, I think Python has many advantages -- if
> your code is well written, there will be a only a few places with
> these sorts of performance bottlenecks, and weave or Cython, or SWIG,
> or Ctypes, or f2py can
Well it is the best pitch for numpy versus matlab I have read so far :)
(and I 100% agree)
Xavier
> On 1/7/2009 4:16 PM, David Cournapeau wrote:
>
>
>> I think on recent versions of matlab, there is nothing you can do
>> without modifying the code: matlab has some JIT compilation for loops,
>>
On 1/7/2009 4:16 PM, David Cournapeau wrote:
> I think on recent versions of matlab, there is nothing you can do
> without modifying the code: matlab has some JIT compilation for loops,
> which is supposed to speed up those cases - at least, that's what is
> claimed by matlab.
Yes it does. After
josef.p...@gmail.com wrote:
> So for simple loops python looses, but for other things, python wins
> by a huge margin.
which emphasizes the point that you can't write code the same way in the
two languages, though I'd argue that that code needs refactoring in any
language!
However, numpy's refe
> Nicolas ROUX wrote:
>> The big trouble I have is a large team of people within my company is ready
>> to replace Matlab by Numpy/Scipy/Matplotlib,
we like that!
>> This is a testcase that people would like to see working without any code
>> restructuring.
>> The reasons are:
>> - this way of
A test case closer to my applications is calling functions in loops:
Python
---
def assgn(a,i,j):
a[i,j,0] = a[i,j,1] + 1.0
a[i,j,2] = a[i,j,0]
a[i,j,1] = a[i,j,2]
return a
print "Start test \n"
dim = 300#0
a = numpy.zeros((dim,dim,3))
start = tim
Here is my example, trying to wrap the function sms_spectrumMag that
we have been dealing with:
%apply (int DIM1, float* IN_ARRAY1) {(int sizeInArray, float* pInArray)};
%apply (int DIM1, float* INPLACE_ARRAY1) {(int sizeOutArray, float* pOutArray)};
%inline %{
void my_spectrumMag( int s
On Wed, Jan 7, 2009 at 10:58 AM, Grissiom wrote:
> On Wed, Jan 7, 2009 at 23:44, Ryan May wrote:
>>
>> Nicolas ROUX wrote:
>> > Hi,
>> >
>> > I need help ;-)
>> > I have here a testcase which works much faster in Matlab than Numpy.
>> >
>> > The following code takes less than 0.9sec in Matlab, bu
> This probably will have no impact on your tests, but this looks like a
> bug. You probably mean:
>
> recXY = numpy.rec.fromarrays((x, y), names='x, y')
Sure! Thanks.
> Could you post the code you use to generate you inputs (ie what is x?)
My code is probably not usable by somebody else tha
On Wed, Jan 7, 2009 at 6:37 AM, Franck Pommereau
wrote:
> def f4 (x, y) :
>"""Jean-Baptiste Rudant
>
>test 1 CPU times: 111.21s
>test 2 CPU times: 13.48s
>
>As Jean-Baptiste noticed, this solution is not very efficient (but
>works almost of-the-shelf).
>"""
>recXY = n
On Wed, Jan 7, 2009 at 23:44, Ryan May wrote:
> Nicolas ROUX wrote:
> > Hi,
> >
> > I need help ;-)
> > I have here a testcase which works much faster in Matlab than Numpy.
> >
> > The following code takes less than 0.9sec in Matlab, but 21sec in Python.
> > Numpy is 24 times slower than Matlab !
> for i in range(dim):
>for j in range(dim):
>a[i,j,0] = a[i,j,1]
>a[i,j,2] = a[i,j,0]
>a[i,j,1] = a[i,j,2]
> for i = 1:dim
>for j = 1:dim
>a(i,j,1) = a(i,j,2);
>a(i,j,2) = a(i,j,1);
>a(i,j,3) = a(i,j,3);
>end
> end
Hi,
The two loops ar
Nicolas ROUX wrote:
> Hi,
>
> I need help ;-)
> I have here a testcase which works much faster in Matlab than Numpy.
>
> The following code takes less than 0.9sec in Matlab, but 21sec in Python.
> Numpy is 24 times slower than Matlab !
> The big trouble I have is a large team of people within my
Nicolas ROUX wrote:
> Hi,
>
> I need help ;-)
> I have here a testcase which works much faster in Matlab than Numpy.
>
> The following code takes less than 0.9sec in Matlab, but 21sec in Python.
> Numpy is 24 times slower than Matlab !
> The big trouble I have is a large team of people within my
Hi,
I need help ;-)
I have here a testcase which works much faster in Matlab than Numpy.
The following code takes less than 0.9sec in Matlab, but 21sec in Python.
Numpy is 24 times slower than Matlab !
The big trouble I have is a large team of people within my company is ready to
replace Matlab
Hi all,
First, let me say that I'm impressed: this mailing list is probably the
most reactive I've ever seen. I've asked my first question and got
immediately more solutions than time to test them... Many thanks to all
the answerers.
Using the various proposals, I ran two performance tests:
- te
27 matches
Mail list logo