[SciPy-user] how to make a sinc(x) function - "divide by zero" !

Sebastian Haase haase at msg.ucsf.edu
Mon Dec 12 11:32:47 CST 2005

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 option)
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...

>>> F.sinc(0)

Warning: Encountered invalid numeric result(s)  in divide

What is a better way of doing this ?
Sebastian Haase

This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
Numpy-discussion mailing list
Numpy-discussion at lists.sourceforge.net

More information about the SciPy-user mailing list