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

Home » Public Forums » archive » Comparing 2 arrays
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: Comparing 2 arrays [message #55664 is a reply to message #55564] Tue, 28 August 2007 09:20 Go to previous messageGo to previous message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
perfect!! ... we had to move all the equipment form our lab so I
couldn't participate in the debate (never send a post on Sunday if you
don't know what you will be doing on Monday :-)

Thanks all for the clarity of the answer/article!

David, in your example (in this message), you use
NUMBER = (array_1 > array_2) * epsilon
and
NUMBER = (array_1 > array_2) * epsilon * 2 in your article...


Also, but that is for pure curiosity, could it be possible to read
directly the mantissa and the power (see David's article if it sounds
like a foreign language) and to compare them for our 2 numbers? ... 1)
look a the power, if they have any difference, the two values can not be
equal. Then look at the mantissa and asses if the digit values are the
same or not...

Jean


David Fanning wrote:
> Jean H. writes:
>
>> to get back to a previous discussion we had a few month ago about being
>> "sufficiently close to zero", shouldn't it be (data1.A - data2.B) LT
>> epsilon * data1.A , with epsilon=(machar()).eps?
>
> OK, I found that discussion and read it eight or ten times until
> I finally understood it. (Probably why I forgot it before.)
>
> I've put a significantly edited discussion of this
> problem here:
>
> http://www.dfanning.com/code_tips/comparearray.html
>
> In my preferred solution now, I choose a number that
> is "sufficiently close" to zero like this:
>
> epsilon = (MACHAR()).eps
> NUMBER = (array_1 > array_2) * epsilon
>
> Then, the comparison between arrays is done like this:
>
> IF Total(Abs(array_1 - array_2) LT NUMBER) EQ N_Elements(array_1) $
> THEN RETURN, 1 ELSE RETURN, 0
>
> Additional comments welcome if you want to argue further. :-)
>
> Cheers,
>
> David
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: new miracle of minor ticks
Next Topic: Programmatic size adjustment of widgets under Windows vs. UNIX (was "Natural size of explicitly-sized widget")

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

Current Time: Sun Oct 12 10:04:39 PDT 2025

Total time taken to generate the page: 1.60085 seconds