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 #79030] Mon, 23 January 2012 15:27 Go to previous message
wallabadah is currently offline  wallabadah
Messages: 28
Registered: November 2005
Junior Member
Here's a quick wrapper that checks for NaNs in the input, and returns true for the above test case. I haven't tested it extensively, but it seems to solve my current problem.

function wjp_array_equal, op1, op2, no_typeconv = no_typeconv
compile_opt idl2

op1NaN = where(finite(op1, /NaN), op1NaNCount, complement = op1Finite)
op2NaN = where(finite(op2, /NaN), op2NaNCount, complement = op2Finite)

; if no NaN values are present, use the normal array_equal() function
if op1NaNCount eq 0 && op2NaNCount eq 0 then $
return, array_equal(op1, op2, no_typeconv = no_typeconv)

; if counts of NaN values are equal, and results of the two where()
; functions are the same, compare the non-NaN values using array_equal()
if op1NaNCount eq op2NaNCount && array_equal(op1Finite, op2Finite) then $
return, array_equal(op1[op1Finite], op2[op2Finite], no_typeconv = no_typeconv)

; otherwise return 0
return, 0
end
[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: Wed Oct 08 17:26:06 PDT 2025

Total time taken to generate the page: 0.00440 seconds