Re: [Numpy-discussion] simple reduction question

2014-12-24 Thread Charles R Harris
On Wed, Dec 24, 2014 at 10:29 AM, wrote: > > > On Wed, Dec 24, 2014 at 10:30 AM, Julian Taylor < > jtaylor.deb...@googlemail.com> wrote: > >> On 24.12.2014 16:25, Neal Becker wrote: >> > What would be the most efficient way to compute: >> > >> > c[j] = \sum_i (a[i] * b[i,j]) >> > >> > where a[i]

Re: [Numpy-discussion] simple reduction question

2014-12-24 Thread josef.pktd
On Wed, Dec 24, 2014 at 10:30 AM, Julian Taylor < jtaylor.deb...@googlemail.com> wrote: > On 24.12.2014 16:25, Neal Becker wrote: > > What would be the most efficient way to compute: > > > > c[j] = \sum_i (a[i] * b[i,j]) > > > > where a[i] is a 1-d vector, b[i,j] is a 2-d array? > > > > This seems

Re: [Numpy-discussion] Fast sizes for FFT

2014-12-24 Thread RayS
At 06:47 PM 12/23/2014, you wrote: The performance of fftpack depends very strongly on the array size -- sizes that are powers of two are good, but also powers of three, five and seven, or numbers whose only prime factors are from (2,3,5,7). For problems that can use padding, rounding up the si

Re: [Numpy-discussion] Fast sizes for FFT

2014-12-24 Thread Luke Pfister
On Wed, Dec 24, 2014 at 7:56 AM, Sturla Molden wrote: > On 24/12/14 14:34, Sturla Molden wrote: > > I would rather have SciPy implement this with the overlap-and-add method > > rather than padding the FFT. Overlap-and-add is more memory efficient > > for large n: > > (eh, the list should be) > >

Re: [Numpy-discussion] simple reduction question

2014-12-24 Thread Neal Becker
Nathaniel Smith wrote: > On Wed, Dec 24, 2014 at 3:25 PM, Neal Becker wrote: >> What would be the most efficient way to compute: >> >> c[j] = \sum_i (a[i] * b[i,j]) >> >> where a[i] is a 1-d vector, b[i,j] is a 2-d array? > > I think this formula is just np.dot(a, b). Did you mean c = \sum_j > \

Re: [Numpy-discussion] simple reduction question

2014-12-24 Thread Nathaniel Smith
On Wed, Dec 24, 2014 at 3:25 PM, Neal Becker wrote: > What would be the most efficient way to compute: > > c[j] = \sum_i (a[i] * b[i,j]) > > where a[i] is a 1-d vector, b[i,j] is a 2-d array? I think this formula is just np.dot(a, b). Did you mean c = \sum_j \sum_i (a[i] * b[i, j])? > This seems

Re: [Numpy-discussion] simple reduction question

2014-12-24 Thread Julian Taylor
On 24.12.2014 16:25, Neal Becker wrote: > What would be the most efficient way to compute: > > c[j] = \sum_i (a[i] * b[i,j]) > > where a[i] is a 1-d vector, b[i,j] is a 2-d array? > > This seems to be one way: > > import numpy as np > a = np.arange (3) > b = np.arange (12).reshape (3,4) > c = n

[Numpy-discussion] simple reduction question

2014-12-24 Thread Neal Becker
What would be the most efficient way to compute: c[j] = \sum_i (a[i] * b[i,j]) where a[i] is a 1-d vector, b[i,j] is a 2-d array? This seems to be one way: import numpy as np a = np.arange (3) b = np.arange (12).reshape (3,4) c = np.dot (a, b).sum() but np.dot returns a vector, which then need

Re: [Numpy-discussion] Fast sizes for FFT

2014-12-24 Thread Sturla Molden
On 24/12/14 14:34, Sturla Molden wrote: > I would rather have SciPy implement this with the overlap-and-add method > rather than padding the FFT. Overlap-and-add is more memory efficient > for large n: (eh, the list should be) - Overlap-and-add is more memory efficient for large n. - It scales

Re: [Numpy-discussion] Fast sizes for FFT

2014-12-24 Thread Sturla Molden
On 24/12/14 04:33, Robert McGibbon wrote: > Alex Griffing pointed out on github that this feature was recently added > to scipy in https://github.com/scipy/scipy/pull/3144. Sweet! I would rather have SciPy implement this with the overlap-and-add method rather than padding the FFT. Overlap-and-ad

Re: [Numpy-discussion] Fast sizes for FFT

2014-12-24 Thread Sturla Molden
On 24/12/14 13:23, Julian Taylor wrote: > hm this is a brute force search, probably fast enough but slower than > scipy's code (if it also were cython) That was what I tought as well when I wrote it. But it turned out that regular numbers are so close and abundant that was damn fast, even in Py

Re: [Numpy-discussion] Fast sizes for FFT

2014-12-24 Thread Julian Taylor
On 24.12.2014 13:07, Sturla Molden wrote: > On 24/12/14 04:33, Robert McGibbon wrote: >> Alex Griffing pointed out on github that this feature was recently added >> to scipy in https://github.com/scipy/scipy/pull/3144. Sweet! > > > I use different padsize search than the one in SciPy. It would be

Re: [Numpy-discussion] Fast sizes for FFT

2014-12-24 Thread Sturla Molden
On 24/12/14 13:07, Sturla Molden wrote: > v > > cdef intp_t checksize(intp_t n): > while not (n % 5): n /= 5 > while not (n % 3): n /= 3 > while not (n % 2): n /= 2 > return (1 if n == 1 else 0) > > def _next_regular(target): > cdef intp_t n = target > while not

Re: [Numpy-discussion] Fast sizes for FFT

2014-12-24 Thread Sturla Molden
On 24/12/14 04:33, Robert McGibbon wrote: > Alex Griffing pointed out on github that this feature was recently added > to scipy in https://github.com/scipy/scipy/pull/3144. Sweet! I use different padsize search than the one in SciPy. It would be interesting to see which is faster. from numpy c

Re: [Numpy-discussion] Fast sizes for FFT

2014-12-24 Thread Julian Taylor
I still have the plan to add this function as public api to numpy's fft helper functions, though I didn't get to it yet. Its a relative simple task if someone wants to contribute. On 24.12.2014 04:33, Robert McGibbon wrote: > Alex Griffing pointed out on github that this feature was recently added