|
From: Andy D. <dou...@la...> - 2002-01-08 14:22:37
|
On Mon, 7 Jan 2002, David Scherer wrote:
> This happens to be an easy one.
>=20
> Change the for loop in the na=EFve version from:
>=20
> for n in range(npts):
> x =3D pulse.gcurve.pos[n][0]
> pulse.gcurve.pos[n][1] =3D yt(x, t)
>=20
> to:
>=20
> x =3D pulse.gcurve.pos[:,0]
> pulse.gcurve.pos[:,1] =3D yt(x, t)
Ah, wonderful. Thanks, that indeed does it and was the sort of insight I
was looking for.
(Even looking back, I still don't see in the NumPy documentation just why
this works. It looks to me from the documentation that only "ufuncs"
operate on arrays element-by-element, not arbitrary user-defined
functions. Yet the actual behavior is exactly what I want in this case.)
Thanks again,
Andy Dougherty dou...@la...
Dept. of Physics
Lafayette College, Easton PA 18042
|