LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fastest way to get indices of an element in a array

Hi Ppl,
 
I want to know which is the fastest way to find all the indices of an element from a 2D array.
I used the below approach. Is there a faster way ? 

Image.JPG 

0 Kudos
Message 1 of 2
(2,721 Views)

There are a couple of things wrong with your approach, the most obvious performance penalty is due to the fact that you are building an array in a loop, causing constant memory reallocations.

 

You also have your cluster defined wrong, because there are coercion dots. The cluster elements must all be I32.

 

Here's what I would probably do, but there are many ways to do all this. Depending on how you define your indices, you might want to swap x and y. I did not compare with your version, so you might need to tweak a few more things. Modify as needed.

 

 

Why don't you code a few alternatives and do some benchmarking on large arrays?

 

Message Edited by altenbach on 07-28-2009 01:13 AM
Message 2 of 2
(2,697 Views)