comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Looking for more ideas on code ...
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Looking for more ideas on code ... [message #32346 is a reply to message #32276] Wed, 02 October 2002 07:13 Go to previous message
meinel is currently offline  meinel
Messages: 14
Registered: February 1994
Junior Member
jeyadev@wrc.xerox.bounceback.com (Surendar Jeyadev) wrote in message news:<anac2a$53h$1@news.wrc.xerox.com>...
> function sinc, y
>
>
> if(n_elements(y) eq 1) then begin ; y is a scalar
> if(y eq 0.0) then profile = 1.0 else begin
> profile = sin(y)/y
> endelse
> endif else begin ; y is a vector
> zeros = where(y eq 0.0, ind)
> if(ind gt 0) then y(zeros) = 1.0e-10 ; set zeroes to a small quantity
> profile = sin(y)/y
> endelse
>
> profile = profile*profile/a0
>
>
> return, profile
>
> end

Neat tricks! But, how about the one-line solution:

profile = (sin(y) + (y EQ 0))/(y + (y EQ 0))

Ed M
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: ROI application...
Next Topic: Re: Array comparison

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 04:51:01 PDT 2025

Total time taken to generate the page: 2.39974 seconds