Re: where() and IEEE NaN [message #17717] |
Mon, 08 November 1999 00:00  |
korpela
Messages: 59 Registered: September 1993
|
Member |
|
|
In article <806t4k$mt0@post.gsfc.nasa.gov>,
William Thompson <thompson@orpheus.nascom.nasa.gov> wrote:
> I thought the only platform that wasn't IEEE compliant was OpenVMS, where the
> VAX floating point notation doesn't included NaN values.
There are also problems on many X86 platforms, where one usually has to set
a compiler flag in order to get IEEE compatibile code out of the compilers.
I'm pretty sure the Windows version is not compliant. Don't know about the
linux versions.
> Actually, the comment that the above command is confusing to people who don't
> know what's going on is valid. Vincenzo's suggestion of using FINITE(/NaN) is
> probably better, and should be (at least) just as fast.
Point taken. I'll b&m about any numerical software that doesn't at least make
the attempt to be IEEE compliant, or at least consistant across platforms.
Eric
--
Eric Korpela | An object at rest can never be
korpela@ssl.berkeley.edu | stopped.
<a href="http://sag-www.ssl.berkeley.edu/~korpela">Click for home page.</a>
|
|
|
|
|
Re: where() and IEEE NaN [message #17726 is a reply to message #17717] |
Mon, 08 November 1999 00:00   |
thompson
Messages: 584 Registered: August 1991
|
Senior Member |
|
|
korpela@islay.ssl.berkeley.edu (Eric J. Korpela) writes:
> In article <7vvkuf$hk4@post.gsfc.nasa.gov>,
> William Thompson <thompson@orpheus.nascom.nasa.gov> wrote:
>> Isn't it simpler (and faster) to say
>>
>> IDL> print,where(a ne a)
> It is on IEEE compliant platforms. But IDL on some platforms
> is not IEEE compliant. My solution is not to use those platforms.
> If forced to use one of those platforms by my employer, my solution would
> be not to use IDL. Anyone at RSI listening?
I thought the only platform that wasn't IEEE compliant was OpenVMS, where the
VAX floating point notation doesn't included NaN values. However, didn't RSI
recently change the OpenVMS version to use IEEE floating point numbers instead,
so that it's now IEEE compliant too. Of course, it may be that I'm missing
something more subtle, or there's some non-IEEE platform out there I'm not
familiar with.
Actually, the comment that the above command is confusing to people who don't
know what's going on is valid. Vincenzo's suggestion of using FINITE(/NaN) is
probably better, and should be (at least) just as fast.
Cheers,
William Thompson
|
|
|
Re: where() and IEEE NaN [message #17762 is a reply to message #17717] |
Thu, 11 November 1999 00:00  |
jsb
Messages: 12 Registered: June 1997
|
Junior Member |
|
|
William Thompson (thompson@orpheus.nascom.nasa.gov) wrote:
: I thought the only platform that wasn't IEEE compliant was OpenVMS, where the
: VAX floating point notation doesn't included NaN values. However, didn't RSI
: recently change the OpenVMS version to use IEEE floating point numbers instead,
: so that it's now IEEE compliant too. Of course, it may be that I'm missing
That is correct. Since the VAX predates IEEE arithmetic, and emulating it
is so putrescent, RSI decided to end support for IDL on the VAX as of V5.1,
IIRC. The Alpha/VMS version of IDL now uses IEEE arithmetic by default.
|
|
|
|
Re: where() and IEEE NaN [message #17794 is a reply to message #17793] |
Sat, 06 November 1999 00:00  |
Vincenzo Andretta
Messages: 1 Registered: November 1999
|
Junior Member |
|
|
Try:
WHERE(FINITE(array,/NaN) eq 1)
Example:
IDL> array=[1.0,!VALUES.F_Infinity,-!VALUES.F_Infinity,!VALUES.F_ NaN]
IDL> print,where(finite(array) eq 0)
1 2 3
IDL> print,where(finite(array,/NaN) eq 1)
3
IDL> print,where(finite(array,/infinity) eq 1)
1 2
Note that IDL seems to be able to deal with "infinities", at least to some
extent:
IDL> print,min(array),max(array)
-Inf Inf
% Program caused arithmetic error: Floating illegal operand
IDL> print,1./array
1.00000 0.00000 -0.00000 NaN
I wouldn't rely on this behaviour, but it is conceivable one might want
to know where NaN values are, while ignoring infinities.
Vincenzo Andretta
CUA,NASA/GSFC - Laboratory for Astronomy and Solar Physics
Greenbelt, MD 20771 - USA
P.S:
IDL> help,/structure,!version
** Structure !VERSION, 5 tags, length=80:
ARCH STRING 'alpha'
OS STRING 'OSF'
OS_FAMILY STRING 'unix'
RELEASE STRING '5.2'
BUILD_DATE STRING 'Oct 30 1998'
|
|
|
Re: where() and IEEE NaN [message #17798 is a reply to message #17793] |
Fri, 05 November 1999 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Pavel Romashkin (promashkin@cmdl.noaa.gov) writes:
> I am not sure if trying to use WHERE on NaN is legitimate. NaN is a
> missing value by definition, and the request to WHERE those values is
> senseless.
Spoken like a software developer, Pavel! Bravo! :-)
> However, I'd too better like WHERE to complain than to
> quietly return some array.
Uh, well, yeah. :-(
> It does not seem to be a *practical* problem because NaNs don't sneak
> into your arrays unless you place them in.
Or, more likely read them from a file of someone else's
data, where they can sometimes cause all kinds of havoc.
> As for whether its right or wrong, I think someone said it before: iI am
> more interested in how to do what I need, not in how I think they did it
> wrong.
Really!? Now you sound like a computer programmer. I'm
confused. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
|
Re: where() and IEEE NaN [message #17803 is a reply to message #17798] |
Fri, 05 November 1999 00:00  |
Pavel Romashkin
Messages: 166 Registered: April 1999
|
Senior Member |
|
|
I am not sure if trying to use WHERE on NaN is legitimate. NaN is a
missing value by definition, and the request to WHERE those values is
senseless. However, I'd too better like WHERE to complain than to
quietly return some array.
It does not seem to be a *practical* problem because NaNs don't sneak
into your arrays unless you place them in. And if you do, then handle
them accordingly.
As for whether its right or wrong, I think someone said it before: iI am
more interested in how to do what I need, not in how I think they did it
wrong.
Cheers,
Pavel
Todd Bowers wrote:
> IDL> a = [1,2,!Values.F_NaN,4,!Values.F_NaN]
> IDL> print, a
> 1.00000 2.00000 NaN 4.00000 NaN
> IDL> print, where(a EQ !Values.F_NaN)
> 0 1 2 3 4
>
> Hmmmmmm.... is this a known feature? The where() help says
> nothin' about NaN's.
> IDL v5.2a
>
> Thanks
> Todd
|
|
|
Re: where() and IEEE NaN [message #17807 is a reply to message #17803] |
Fri, 05 November 1999 00:00  |
thompson
Messages: 584 Registered: August 1991
|
Senior Member |
|
|
badastro@smart.net (Philip Plait) writes:
> In article <7vv1j3$6ro$1@ra.nrl.navy.mil>,
> Todd Bowers <tbowers@nrlssc.navy.mil> wrote:
>> IDL> a = [1,2,!Values.F_NaN,4,!Values.F_NaN]
>> IDL> print, a
>> 1.00000 2.00000 NaN 4.00000 NaN
>> IDL> print, where(a EQ !Values.F_NaN)
>> 0 1 2 3 4
>>
>> Hmmmmmm.... is this a known feature? The where() help says
>> nothin' about NaN's.
>> IDL v5.2a
> Incidentally, if you are looking for the element numbers
> of where a = NaN, try:
> IDL> print,where(a-a ne 0)
> 2 4
Isn't it simpler (and faster) to say
IDL> print,where(a ne a)
William Thompson
|
|
|
|
Re: where() and IEEE NaN [message #17815 is a reply to message #17813] |
Fri, 05 November 1999 00:00  |
badastro
Messages: 7 Registered: August 1998
|
Junior Member |
|
|
In article <7vv1j3$6ro$1@ra.nrl.navy.mil>,
Todd Bowers <tbowers@nrlssc.navy.mil> wrote:
>IDL> a = [1,2,!Values.F_NaN,4,!Values.F_NaN]
>IDL> print, a
> 1.00000 2.00000 NaN 4.00000 NaN
>IDL> print, where(a EQ !Values.F_NaN)
> 0 1 2 3 4
>
>Hmmmmmm.... is this a known feature? The where() help says
>nothin' about NaN's.
>IDL v5.2a
Incidentally, if you are looking for the element numbers
of where a = NaN, try:
IDL> print,where(a-a ne 0)
2 4
;-)
* * * * * The Bad Astronomer * * * *
Phil Plait badastro@badastronomy.com
The Bad Astronomy Web Page: http://www.badastronomy.com
|
|
|
Re: where() and IEEE NaN [message #17816 is a reply to message #17815] |
Fri, 05 November 1999 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Todd Bowers (tbowers@nrlssc.navy.mil) writes:
> IDL> a = [1,2,!Values.F_NaN,4,!Values.F_NaN]
> IDL> print, a
> 1.00000 2.00000 NaN 4.00000 NaN
> IDL> print, where(a EQ !Values.F_NaN)
> 0 1 2 3 4
>
> Hmmmmmm.... is this a known feature?
Sure. Well known. :-)
I usually check for NANs like this:
IDL> Print, Where( NOT Float( Finite(a) ) )
2 4
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: where() and IEEE NaN [message #17818 is a reply to message #17816] |
Fri, 05 November 1999 00:00  |
korpela
Messages: 59 Registered: September 1993
|
Member |
|
|
In article <7vv1j3$6ro$1@ra.nrl.navy.mil>,
Todd Bowers <tbowers@nrlssc.navy.mil> wrote:
> IDL> a = [1,2,!Values.F_NaN,4,!Values.F_NaN]
> IDL> print, a
> 1.00000 2.00000 NaN 4.00000 NaN
> IDL> print, where(a EQ !Values.F_NaN)
> 0 1 2 3 4
>
> Hmmmmmm.... is this a known feature? The where() help says
> nothin' about NaN's.
> IDL v5.2a
Unfortunately, on some platforms IDL is not IEEE compliant which greatly
limits IDL's usefulness as a cross platform system. RSI could easily fix
this on most platforms with a compiler option, but they choose not to.
The only correct response for any array to "print,where(a eq !values.F_NaN)"
is "-1".
Eric
--
Eric Korpela | An object at rest can never be
korpela@ssl.berkeley.edu | stopped.
<a href="http://sag-www.ssl.berkeley.edu/~korpela">Click for home page.</a>
|
|
|