jccorreu Posted January 5, 2008 Report Share Posted January 5, 2008 This is 7.1.1. I've created an array of clusters of doubles, each double having exactly the same properties. For each cluster in the array, I do some simple math, and create an intermediate 1D array of doubles containing the same number of elements as the total number of doubles present in the original array of clusters. I then repeatedly search the array to remove duplicates using the remove duplicates vi from OpenG (here I simply placed the code in line for ease of readability). Then I sort that output array. In one case I've found that a duplicate is not being removed. Specifically the value 0.3. But it is slightly more complex than that becuase some of them are being removed. Out of 4 instances of that value, I am left with 2 instances. What seems truly strange is when I run on higlight execution, it becomes evident that the ones being removed have a specific pattern or relation to which is found when the search array primitive is called.... In the intermediate array it appears that elements 3 and 5 are related, and elements 6 and 8 are related, as far as the search array primitive is concerned. I.e. during the iteration during which we search for the 5th element, the search primitive finds its element as related to where the 3rd element was placed. Yet the iteration for the 6th element finds nothing, and the 8th element is given the search primtive element relating to the 6th element. I noticed that those pairs are related to that simple math I did to create the intermediate array. Elements 3 and 5 were arrived at through addition. Elements 6 and 8 were simply moved straight through. So I decided to change the values in my original array that led to values of 0.3 in the intermediate array, and everything worked as it should. So it seems to be, at first glance, something to do with that particular value, and the different ways that value is arrived at, that the search primitive does not see as being the same. Anyone see something I am missing? Any one see anything like this before? Anyone have an alternative solution? etc... thanks James Download File:post-8730-1199418756.vi Oops I forgot to include the data that I'm using. Array 1 .1 .2 .3 .1 .1 .1 .2 .3 .2 .1 .1 .2 Array 2 .1 .2 .5 .1 .3 .1 .2 .5 .2 .3 .1 .2 In addition I've found that adding 0 does not produce this result. Array 3 .3 .3 .3 0 0 0 .1 .1 .1 .2 .2 .2 Quote Link to comment
Ton Plomp Posted January 5, 2008 Report Share Posted January 5, 2008 This is a floating point issue, derived from the fact your 0.3 != (0.2+0.1). To see this expand the 'sorted array' to have 20 digits: A LabVIEW wiki on this is Numeric. The second paragraph titled 'Comparing real numbers' is of your interest. A wikipedia article on this issue can be found here. Ton Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.