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

Home » Public Forums » archive » Re: odd behaviour from array_equal() with NaN, Inf 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
Re: odd behaviour from array_equal() with NaN, Inf values [message #79038 is a reply to message #79037] Sun, 22 January 2012 21:46 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Jan 22, 11:42 pm, wallabadah <write.to.wpow...@gmail.com> wrote:
> I've come across the following behaviour while tracking down odd behaviour from NaN and Inf values. I'm trying to use array_equal() to check that arrays contain the same content - but it bombs when the arrays contain NaN. I've tracked it down to the process of copying an array containing NaN values to a new variable. For example:
>
> IDL> a = findgen(5)
> IDL> a[1] = !values.f_nan
> IDL> print, array_equal(a, a)
>    1
> IDL> b = a
> IDL> print, array_equal(a, b)
>    0
> IDL> print, array_equal(b, b)
>    1
>
> Repeating the process with !values.f_infinity behaves as expected:
>
> IDL> a = findgen(5)
> IDL> a[1] = !values.f_infinity
> IDL> print, array_equal(a, a)
>    1
> IDL> b = a
> IDL> print, array_equal(a, b)
>    1
> IDL> print, array_equal(b, b)
>    1
>
> Is this a bug in make_array() or some artifact of how values are copied to new variables?? Is it reproducible on different platforms (I'm on Mac OS X, IDL 8.1).

Greetings--

I think it's a subtle bug in ARRAY_EQUAL(). ARRAY_EQUAL(A,A) *should*
return 0 for your case.

It is a property of NAN that it can never equal itself so - perhaps
surprisingly -
(A[1] EQ A[1]) is false. Try it yourself!

I suspect that the IDL folks decided to put an special case
optimization in to the code which always returned true when the same
variable is passed in both parameter positions. Unfortunately, this
fails when one more more elements is NAN.

Craig
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Cramér–von Mises criterion
Next Topic: to read excel file in IDL

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

Current Time: Fri Oct 10 03:44:47 PDT 2025

Total time taken to generate the page: 1.28084 seconds