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

Home » Public Forums » archive » Re: where() and IEEE NaN
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: where() and IEEE NaN [message #17717] Mon, 08 November 1999 00:00 Go to next message
korpela is currently offline  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 #17719 is a reply to message #17717] Mon, 08 November 1999 00:00 Go to previous messageGo to next message
badastro is currently offline  badastro
Messages: 7
Registered: August 1998
Junior Member
In comp.lang.idl-pvwave Eric J. Korpela <korpela@islay.ssl.berkeley.edu> wrote:
> 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.

I had a DEC Alpha for a few years that some, um, interesting
effects in IDL. I'm on a sparc now and have no problems.
I cannot remember the details now, but a couple of years ago we had
this NaN problem. I typed in print,where(a ne a) and it barfed. So
I did the workaround of hh = where(a-a ne 0) and it worked.


* * * * * The Bad Astronomer * * * *

Phil Plait badastro@badastronomy.com
The Bad Astronomy Web Page: http://www.badastronomy.com
Re: where() and IEEE NaN [message #17723 is a reply to message #17717] Mon, 08 November 1999 00:00 Go to previous messageGo to next message
Pavel Romashkin is currently offline  Pavel Romashkin
Messages: 166
Registered: April 1999
Senior Member
> Spoken like a software developer

Well, when you are trying to find a justification for the misbehavior of the
software you like, you tend to find logical excuses. Isn't that what
developers do when they did not think of something useful?

> Really!? Now you sound like a computer programmer. I'm
> confused. :-)

This is because I want to get some things done eventually. After all, isn't
software developer a breed of computer programmer?

Sorry for the confusion, David. My beer debt is growing :-)

Cheers,
Pavel
Re: where() and IEEE NaN [message #17726 is a reply to message #17717] Mon, 08 November 1999 00:00 Go to previous messageGo to next message
thompson is currently offline  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 Go to previous message
jsb is currently offline  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 #17793 is a reply to message #17717] Sat, 06 November 1999 00:00 Go to previous message
korpela is currently offline  korpela
Messages: 59
Registered: September 1993
Member
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?

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 #17794 is a reply to message #17793] Sat, 06 November 1999 00:00 Go to previous message
Vincenzo Andretta is currently offline  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 Go to previous message
davidf is currently offline  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 #17799 is a reply to message #17798] Fri, 05 November 1999 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
William Thompson (thompson@orpheus.nascom.nasa.gov) writes:

> Isn't it simpler (and faster) to say
>
> IDL> print,where(a ne a)

Simpler. Yes. Faster. Yes.

But don't you think the poor sucker reading your
code 10 years from now will be scratching his head?

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 Go to previous message
Pavel Romashkin is currently offline  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 Go to previous message
thompson is currently offline  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 #17813 is a reply to message #17807] Fri, 05 November 1999 00:00 Go to previous message
T Bowers is currently offline  T Bowers
Messages: 56
Registered: May 1998
Member
AAARRRGGGHHH! It's like the movie.
IDL has hurt me, and it wishes to go on.... hurting me!

Thanks Dave, Eric, Philip.
Re: where() and IEEE NaN [message #17815 is a reply to message #17813] Fri, 05 November 1999 00:00 Go to previous message
badastro is currently offline  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 Go to previous message
davidf is currently offline  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 Go to previous message
korpela is currently offline  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>
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Center of mass???
Next Topic: Re: contour plots on walls of a cube

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

Current Time: Wed Oct 08 14:00:59 PDT 2025

Total time taken to generate the page: 0.00719 seconds