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

Home » Public Forums » archive » Re: Combinatorial
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Combinatorial [message #40755 is a reply to message #40754] Fri, 27 August 2004 07:12 Go to previous messageGo to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Kenneth Bowman wrote:
> In article <e8ecd642.0408270539.19ddd96a@posting.google.com>,
> andrade_bahia@yahoo.com.br (Adilson) wrote:
>
>
>> Dear all,
>> Would like to know as I make to effect combinations in the IDL I have
>> a problem where I want to execute a fixed combination of elements
>> contained in a vector. EX: A=[0,1,2,3,4,5 ] --> six elements I want
>> to make combinations 3x3 of the elements contained in. The formed
>> vector is of 6!/3!*(6-3)! = 20 elements. Example of the vector to be
>> formed->[0,1,2],[0,1,3]... [3,4,5 ]. In the total of 20 combinations.
>> Which the best form to execute this operation? If you to be able to
>> help me would be grateful.
>> I subscribe myself with the highest consideration.
>> Thanks in advance for your help.
>>
>> Adilson
>
>
> Not elegant, but I think this does what you want.

Looks pretty bloody elegant to me after the dreck I posted! :o)

>
> IDL> n = 6
> IDL> comb = lonarr(3)
> IDL> for i = 0, n-1 do for j = i+1, n-1 do for k = j+1, n-1 do comb =
> [[comb], [i,j,k]]
> IDL> comb = comb[*,1:*]
> IDL> print, comb
> 0 1 2
> 0 1 3
> 0 1 4
> 0 1 5
> 0 2 3
> 0 2 4
> 0 2 5
> 0 3 4
> 0 3 5
> 0 4 5
> 1 2 3
> 1 2 4
> 1 2 5
> 1 3 4
> 1 3 5
> 1 4 5
> 2 3 4
> 2 3 5
> 2 4 5
> 3 4 5
>
> Ken Bowman
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Beyond 7-bit ASCII
Next Topic: Re: User Interface realization in IDL

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

Current Time: Tue Dec 02 07:52:46 PST 2025

Total time taken to generate the page: 0.24334 seconds