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 #40720 is a reply to message #40719] Tue, 31 August 2004 06:02 Go to previous messageGo to previous message
andrade_bahia is currently offline  andrade_bahia
Messages: 5
Registered: August 2004
Junior Member
Dear Bowman
I obtained to make the combinations without needing to use recursive form.
Thanks in advance for your help.
;*********************************************************** *************
FUNCTION Combination,n,k
c=lindgen(k)
cmax=N-reverse(lindgen(k))-1
i=k-1
comb=c
while i GE 0 do begin
c[i]=c[i]+1
if c[i] GT cmax[i] then begin
i=max(where(c lt cmax))
if i eq -1 then break
c[i]=c[i]+1
for j=i+1, k-1 do c[j]=c[j-1]+1
i=k-1
endif
comb= [[comb],[c]]
;stop
endwhile
return, com
END
Adilson




Kenneth Bowman <k-bowman@null.tamu.edu> wrote in message news:<k-bowman-A330BB.12580030082004@news.tamu.edu>...
> In article <e8ecd642.0408300658.5304ce28@posting.google.com>,
> andrade_bahia@yahoo.com.br (Adilson) wrote:
>
>> Dear Bowman,
>> I Would like to thank the orientation.
>> But if the combination will be of more attributes, or either, 4x4,
>> 5x5?? How I could make?
>> Thanks in advance for your help.
>>
>> Adilson Andrade
>
> Same idea. To choose m items, you will need to nest m FOR loops. I'm
> sure other algorithms could be devised that have only a single loop.
>
> 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 09:25:09 PST 2025

Total time taken to generate the page: 0.15854 seconds