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

Home » Public Forums » archive » NaN problems
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: NAN Problem [message #69399 is a reply to message #43584] Wed, 13 January 2010 12:59 Go to previous messageGo to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Jan 13, 6:23 pm, David Fanning <n...@dfanning.com> wrote:
> Folks,
>
> Consider this sequence of commands on my IDL 7.0.1
> LINUX version.
>
>    IDL> a = Findgen(11)
>    IDL> a[0] = !Values.F_NAN
>    IDL> Print, Min(a), Max(a)
>            NaN   NaN
>    IDL> b = Findgen(11)
>    IDL> b[1] = !Values.F_NAN
>    IDL> Print, Min(b), Max(b)
>           0.00000   10.00000
>
> What do you make of that? This is giving me a great
> deal of touble today while trying to elminate bad
> values from an image. :-(
>
> I have the same results with my Windows IDL 7.1.2
> version, except I do get a warning about a floating
> illegal operand with variable b, which I don't get
> on LINUX.

Interesting. I found the same here, with 7.1.1 in Linux. I had never
noticed this behavior before.

I do not know how the min and max functions were implemented, but this
would be the result of one algorithms that could be used for it. Since
NaN does not compare larger or smaller than anything, the following
would produce the same result:

function min_test,a
res=a[0]
for i=1,n_elements(a)-1 do if a[i] lt res then res=a[i]
return,res
end

When the NaN is the first element, it will be set as the initial value
for the minimum, and since nothing is smaller, it will be kept as the
result. Conversely, if the first value is not NaN, no NaN value that
comes after will be smaller than it, so an NaN would not replace the
minimum.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: NAN Problem
Next Topic: Re: aggregate pixel values within shapes or another raster

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

Current Time: Fri Nov 28 22:41:13 PST 2025

Total time taken to generate the page: 4.00239 seconds