Re[2]: [Numpy-discussion] convolve
![](https://secure.gravatar.com/avatar/39916bae984cb93b797efd2b175f59c0.jpg?s=120&d=mm&r=g)
On Wed, 27 Jul 2005, René Bastian apparently wrote:
Outcommenting if len(data) < len(kernel): data, kernel = kernel, data in convolve.py gives the correct result.
The author is not listed for this numarray module, so we cannot directly ask why this behavior was chosen. You might use Numeric.convolve instead of numarray.convolve.Convolve.convolve: Numeric gives the expected result here. fwiw, Alan Isaac
![](https://secure.gravatar.com/avatar/ec366db3649cf13f4061b519193849d6.jpg?s=120&d=mm&r=g)
Alan G Isaac wrote:
On Wed, 27 Jul 2005, René Bastian apparently wrote:
Outcommenting if len(data) < len(kernel): data, kernel = kernel, data in convolve.py gives the correct result.
The author is not listed for this numarray module, so we cannot directly ask why this behavior was chosen.
This behavior was chosen for performance reasons. Since convolution is commutative, it doesn't matter what order the arguments come in. I do not see the behavior René is claiming. Perhaps René can tell us what version of numarray he is using? or provide an example? I am using CVS as of a week ago, I think. In [10]: import numarray In [11]: import numarray.convolve In [12]: a = numarray.arange(10) + 1. In [13]: b = numarray.arange(5) + 2. In [14]: c = a - 1. In [15]: numarray.convolve.convolve(a,b) Out[15]: array([ 2., 7., 16., 30., 50., 70., 90., 110., 130., 150., 148., 133., 104., 60.]) In [16]: numarray.convolve.convolve(b,a) Out[16]: array([ 2., 7., 16., 30., 50., 70., 90., 110., 130., 150., 148., 133., 104., 60.]) In [17]: numarray.convolve.convolve(a,c) Out[17]: array([ 0., 1., 4., 10., 20., 35., 56., 84., 120., 165., 210., 244., 266., 275., 270., 250., 214., 161., 90.]) In [18]: numarray.convolve.convolve(c,a) Out[18]: array([ 0., 1., 4., 10., 20., 35., 56., 84., 120., 165., 210., 244., 266., 275., 270., 250., 214., 161., 90.]) -- Robert Kern rkern@ucsd.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter
![](https://secure.gravatar.com/avatar/ec366db3649cf13f4061b519193849d6.jpg?s=120&d=mm&r=g)
Alan G Isaac wrote:
On Wed, 27 Jul 2005, Robert Kern apparently wrote:
I do not see the behavior René is claiming. Perhaps René can tell us what version of numarray he is using?
I see it in version 1.1, for the example he provided.
What example? Either his message has not yet propogated to me or the mailing list archives, or he sent it to you privately. The problem does not seem to exist any longer in CVS. -- Robert Kern rkern@ucsd.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter
![](https://secure.gravatar.com/avatar/39916bae984cb93b797efd2b175f59c0.jpg?s=120&d=mm&r=g)
On Wed, 27 Jul 2005, Robert Kern apparently wrote:
I do not see the behavior René is claiming. Perhaps René can tell us what version of numarray he is using?
Alan G Isaac wrote:
I see it in version 1.1, for the example he provided.
On Wed, 27 Jul 2005, Robert Kern apparently wrote:
What example? Either his message has not yet propogated to me or the mailing list archives, or he sent it to you privately. The problem does not seem to exist any longer in CVS.
My bad. It was indeed off list. It is (essentially) replicated below. Alan ================================================== #-*-coding:latin-1-*- #from Numeric import arrayrange,asarray #from Numeric import convolve from numarray import arrayrange,asarray from numarray.convolve.Convolve import convolve def explo0(): a=arrayrange(10.) b=asarray([1., 0., 2., -1., 3., -2.]) c=convolve(a, b) print c d=convolve(b, a) print d if __name__=="__main__": explo0()
![](https://secure.gravatar.com/avatar/ec366db3649cf13f4061b519193849d6.jpg?s=120&d=mm&r=g)
Alan G Isaac wrote:
On Wed, 27 Jul 2005, Robert Kern apparently wrote:
I do not see the behavior René is claiming. Perhaps René can tell us what version of numarray he is using?
Alan G Isaac wrote:
I see it in version 1.1, for the example he provided.
On Wed, 27 Jul 2005, Robert Kern apparently wrote:
What example? Either his message has not yet propogated to me or the mailing list archives, or he sent it to you privately. The problem does not seem to exist any longer in CVS.
My bad. It was indeed off list. It is (essentially) replicated below.
Whatever problem that once existed is now fixed in CVS. The example you give works fine. -- Robert Kern rkern@ucsd.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter
participants (3)
-
Alan G Isaac
-
René Bastian
-
Robert Kern