05-02-2007 11:08 AM
05-02-2007 11:32 AM
Some other ideas (the problem is easy, because your array is sorted, right?):
05-02-2007 12:56 PM
Thanks! I had a nagging feeling there was something I shoulda thought of myself, but, well, I didn't. With 30 Meg array size, it should only require about 25 iterations. Nice. (Yes, the data is sorted. Not by calling a "sort" function but implicitly, based on the how it was generated). I'd guess that the built-in "Threshold 1D Array" function might be implemented as a binary search already.
I know I've tinkered with doing a binary search before, I think based on a specific cluster element or something like that, but probably never made it into a library-ready sub-vi. Shouldn't be too big a deal though (he said a bit too casually...).
The second method sounds less promising for such a large dataset because:
a) I'd have to allocate a very short-lived 30 Meg Boolean array
b) "Search 1D Array" searches sequentially, right? I might need several orders of magnitude more iterations. Probably not a win no matter how fast each one is.
-Kevin P.
05-02-2007 01:33 PM - edited 05-02-2007 01:33 PM
Message Edited by Jarrod S. on 05-02-2007 01:34 PM
Message Edited by Jarrod S. on 05-02-2007 01:35 PM
05-02-2007 01:42 PM
05-02-2007 04:46 PM - edited 05-02-2007 04:46 PM
Message Edited by Matt W on 05-02-2007 04:48 PM
Message Edited by Matt W on 05-02-2007 04:49 PM
05-02-2007 04:55 PM
@matt W wrote:
...Threshold 1D array for some reason uses a linear search instead of a binary search (I'm not sure why either, but I tested it and it scales linearly, on 32e6 integers it take 84 ms, and on 16e6 integers 42 ms, a binary search takes less than 1 ms). ...
In real life, you cannot assume that the array is sorted, so if you have multiple crossings, a binary search would blow up.
We also have a input for the start index, so you can search for multiple crossings in a loop. I typically have data with multiple zero crossings, but I start searching from the array-min index to get the position I really want.
05-02-2007 06:10 PM
05-03-2007 06:18 AM
Lynn,
Can you pl repost the VI saved for LV 7.1 ?
05-03-2007 06:44 AM - edited 05-03-2007 06:44 AM
Message Edited by Kevin Price on 05-03-2007 07:48 AM