07-28-2009 01:54 AM
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 ?
07-28-2009 03:11 AM - edited 07-28-2009 03:13 AM
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?