01-07-2016 12:05 AM
Hi,
I have a U16 array . The array size is 250000000
The format of each element is as below:
0000 1111 1111 1111 = 4095 , each 1 is for 1 site. This means all 12 sites passed
Let's say element 20000 is : 1011 1111 1111 : this means site 11 failed at step 20000
Now I would like to know what is the fastest way to search through all 2500000000 elements and find the first 0 ( if there is any ) for each site.
I have the following code that does this work but it is really time consuming . Please let me know if you suggest a better way
01-07-2016 01:14 AM
01-07-2016 01:28 AM
01-07-2016 01:47 AM - edited 01-07-2016 01:47 AM
Hi tintin,
find the first 0 ( if there is any ) for each site.
I would use ouadji's suggestion and improve it by changing the constant used for the AND operation: It should contain just one single TRUE bit for the "site" you want to check!
All you need to do now is to call that snippet in a loop using the loop iterator as input for "site"… 😄
01-07-2016 01:52 AM
You have to make some benchmarks to determine which one is faster but this is another solution.
AND : keep only bit corresponding to a site
Search 1D Array : find first equal to 0
01-07-2016 01:55 AM
GerdW posted his answer while I was editing mine and I saw I only after posting it.
01-07-2016 02:04 AM
Where does the array come from?
It is safe to say that you won't be able to do any of this in LabVIEW 32bit, so I am assuming you are using 64bit LabVIEW.
If a failure is a relatively rare event, it might be worth to only retain the failed elements, their index, and their value. It seems redundant to create gigabytes of output arrays where most elements are identical. You also might find a solution that does not need any green arrays.
01-07-2016 03:51 AM
my solution is wrong ... GerdW's solution is better. (dito for the JB's solution)
@ tintin_99 : " .... and find the first 0 ( if there is any ) for each site. "