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 #32345 is a reply to message #32276] Wed, 02 October 2002 07:24 Go to previous messageGo to previous message
thompson is currently offline  thompson
Messages: 584
Registered: August 1991
Senior Member
jeyadev@wrc.xerox.bounceback.com (Surendar Jeyadev) writes:

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

The only suggestion I would make would be to change the last line to

if ct gt 0 then profile(wh) = sin(y(wh))/y(wh)

I've been bitten by that one on countless occasions.

William Thompson
[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 05:07:02 PDT 2025

Total time taken to generate the page: 1.60122 seconds