|
From: Robert K. <rk...@uc...> - 2005-07-27 20:43:34
|
Alan G Isaac wrote:
> On Wed, 27 Jul 2005, Ren=E9 Bastian apparently wrote:=20
>=20
>>Outcommenting
>>if len(data) < len(kernel):
>> data, kernel =3D kernel, data
>>in convolve.py gives the correct result.=20
>=20
> 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=20
commutative, it doesn't matter what order the arguments come in. I do=20
not see the behavior Ren=E9 is claiming. Perhaps Ren=E9 can tell us what=20
version of numarray he is using? or provide an example? I am using CVS=20
as of a week ago, I think.
In [10]: import numarray
In [11]: import numarray.convolve
In [12]: a =3D numarray.arange(10) + 1.
In [13]: b =3D numarray.arange(5) + 2.
In [14]: c =3D 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.])
--=20
Robert Kern
rk...@uc...
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
|