[SciPy-user] how to make a sinc(x) function - "divide by zero" !
perry at stsci.edu
Mon Dec 12 12:13:26 CST 2005
On Dec 12, 2005, at 12:32 PM, Sebastian Haase wrote:
> I was trying to implement a "sinc" [sin(x)/x] in numarray. But the
> "where"-semantics makes it choke on the x=0: 0/0 case.
> (This should of course work for x being an array - so "if" is no
> The best I could come up with was:
> def sinc(r):
> a = na.where(r, na.divide(na.sin(r),r), 1)
> return a
> but I still seem to get a warning...
> Warning: Encountered invalid numeric result(s) in divide
> What is a better way of doing this ?
> Sebastian Haase
That's odd. When I try your example it prints 1 without any warning.
What version and platform are you running on?
More information about the SciPy-user