Re: [Numpy-discussion] Optimizing recursive loop - updated example

2011-07-25 Thread Robert Elsner
I didn't look into that but it definitely sounds interesting. Especially as the coefficient manipulation is mildly unstable for higher derivatives. Need to work out the math first though ;). Thanks for the hint. On 25.07.2011 15:59, Charles R Harris wrote: > On Sun, Jul 24, 2011 at 5:10 PM, Rober

Re: [Numpy-discussion] Optimizing recursive loop - updated example

2011-07-25 Thread Charles R Harris
On Sun, Jul 24, 2011 at 5:10 PM, Robert Elsner wrote: > Boiled it down a bit more to only include code that actually takes time. > First time around I found the other variant more instructive because it > shows the discrepancy between the DCT and the loop but might be > confusing. Thus here the b

Re: [Numpy-discussion] Optimizing recursive loop - updated example

2011-07-25 Thread Pauli Virtanen
Mon, 25 Jul 2011 12:30:34 +0200, Robert Elsner wrote: > Thanks for the hint. I thought about Cython myself but I was unable to > get even the slightest speed gain out of it. Here is the equivalent > Cython code with the timing and setup.py. I typed (I think). Am I > missing something obvious? Cyth

Re: [Numpy-discussion] Optimizing recursive loop - updated example

2011-07-25 Thread Robert Elsner
Yes I did. Slicing and Cython do not mix too well. Using an explicit loop fixes the problem. In case anybody is interested the code is attached. Thanks for your help Robert On 25.07.2011 12:30, Robert Elsner wrote: > Thanks for the hint. I thought about Cython myself but I was unable to > get eve

Re: [Numpy-discussion] Optimizing recursive loop - updated example

2011-07-25 Thread Robert Elsner
Thanks for the hint. I thought about Cython myself but I was unable to get even the slightest speed gain out of it. Here is the equivalent Cython code with the timing and setup.py. I typed (I think). Am I missing something obvious? Cheers Robert On 25.07.2011 01:38, Joon Ro wrote: > For those ca

Re: [Numpy-discussion] Optimizing recursive loop - updated example

2011-07-24 Thread Joon Ro
For those cases where you cannot vectorize the operation, numpy is usually does not help much. Try using Cython. You will be able to compile the part of the code and the loop will be much faster (can be more than 100 times faster). http://docs.cython.org/ -Joon On Sun, 24 Jul 2011 18:10:14

Re: [Numpy-discussion] Optimizing recursive loop - updated example

2011-07-24 Thread Robert Elsner
Boiled it down a bit more to only include code that actually takes time. First time around I found the other variant more instructive because it shows the discrepancy between the DCT and the loop but might be confusing. Thus here the bare minimum that correctly calculates the coefficients of the fi

[Numpy-discussion] Optimizing recursive loop

2011-07-24 Thread Robert Elsner
Hey Everybody, I am approximating the derivative of nonperiodic functions on [-1,1] using Chebyshev polynomials. The implementation is straightforward and works well but is painfully slow. The routine wastes most of its time on a trivial operation (see comment in the code) Unfortunately the spectr