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

Home » Public Forums » archive » MIN(), MAX() with NaN values
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
MIN(), MAX() with NaN values [message #89051] Sat, 19 July 2014 07:24 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
The documentation for MIN() says that

"Note: If the MIN function is run on an array containing NaN values and the NAN keyword is not set, an invalid result will occur."

However, most of the time MIN() seems to work fine with NaN values.

IDL> print,!version
{ x86_64 darwin unix Mac OS X 8.3 Nov 15 2013 64 64}
IDL> a = randomn(seed,500,500)
IDL> a[1,1] = replicate(!values.f_nan,4)
IDL> print,min(a)
-4.76949

The invalid results seem to occur when the NaN values are at the edge of the image (or in the first or last value of a vector)

IDL> a = findgen(10)
IDL> a[0] = !values.f_nan
IDL> print,min(a)
NaN

I can't fault the design or documentation of MIN() -- it says to use /NAN when NaN values are present. But we had difficulty debugging our code since our images have a few randomly located NaN values, and so using MIN() without /NaN was working 99% of the time. We have now added /NaN to the code -- and taken the factor of ~3 speed penalty -- so it works 100% of the time.
[Message index]
 
Read Message
Read Message
Previous Topic: Matrix a*b in loop
Next Topic: mpfitfun

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

Current Time: Wed Oct 08 13:42:11 PDT 2025

Total time taken to generate the page: 0.00438 seconds