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

Home » Public Forums » archive » Re: 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 #32355 is a reply to message #32275] Tue, 01 October 2002 13:11 Go to previous messageGo to previous message
jeyadev is currently offline  jeyadev
Messages: 78
Registered: February 1995
Member
In article <onr8fbugea.fsf@cow.physics.wisc.edu>,
Craig Markwardt <craigmnet@cow.physics.wisc.edu> wrote:
>
> jeyadev@wrc.xerox.bounceback.com (Surendar Jeyadev) writes:
>
>> ....
>>
>> ------------------------------------------
>>
>> 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

My mistake there. I am actually after sinc^2 ..... but it
has not caused any harm!

>> return, profile
>>
>> end
>>
>
> Second of all, you can simplify your logic a little, by pre-filling
> the array with the "special case:"
>
> profile = y*0 + 1. ;; Tricky way to get array filled with zeroes
> wh = where(y NE 0, ct)
> profile(wh) = sin(y(wh))/y(wh)

Nice one that, when the only exceptional value is the same for
all "problem" points.

thanks
--

Surendar Jeyadev jeyadev@wrc.xerox.bounceback.com

Remove 'bounceback' for email address
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Reducing an array.
Next Topic: mpeg next question

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

Current Time: Fri Oct 10 09:48:37 PDT 2025

Total time taken to generate the page: 0.72059 seconds