comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Unique combinations from a 1d array
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Unique combinations from a 1d array [message #37625] Wed, 14 January 2004 14:03 Go to previous message
dapoulio is currently offline  dapoulio
Messages: 2
Registered: January 2004
Junior Member
Does anyone know of a more efficient means to determine the set of all
unique combinations of 2 from a 1d array? The following is an approach
that works but for large arrays -say 3000 or more elements it is very
slow. Part of the problem is due to memory because the number of
paired comparisons becomes very large � i.e. for 3000 elements the
total number of combinations is 4498500. Writing the paired difference
results to a temporary file helped considerably, but is still far too
slow. Any ideas would be much appreciated.

Here is the code I have:

X = [X1, X2, X3�..Xn+1]
n = n_elements(X)
d = make_array(1, /float)
for i=0, n-1 do for j=0, n-1 do begin
if i le j then begin
d = [d, X[i] - X[j]]
endif
endfor
d = d[1:n-1]

Thanks in advance,

Darren
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: IDL vs Direct3D, OpenGL
Next Topic: Throwing objects to Virtual Machine in Unix

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 03:51:36 PDT 2025

Total time taken to generate the page: 1.03851 seconds