Sorting (big) int array: Eliminate for loop [message #68062] |
Mon, 21 September 2009 07:46 |
Luds
Messages: 7 Registered: September 2009
|
Junior Member |
|
|
Hi,
I'm trying to eliminate a for loop form one of my codes, but can't
seem to get around it (though I must be able to, with the histogram
function, or something of the sort)... I was hoping to get some advice
from the (semi-)pros.
Here's what I want to do:
I have two arrays, A & B. Both are sparse and contain non-contiguous
integers. Both are 1-dimensional and have the same number of elements.
Array B contains all the same values as array A, but in a random
order. I want to find the elements with which I can subscript array B
so that it returns A (i.e. I want B(elements)=A).
Trivially I get what I want with
For K = 0L, Narray - 1L do elements[K] = where(B eq A[K])
The arrays contain 10's of millions of elements, so memory is an
issue.... but clearly a For loop is WAY to slow and I'm crazy for even
considering it as an option.
Does anyone have any advice on this?
Thanks 10's of millions!
|
|
|