home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.apl
- Path: sparky!uunet!gatech!rpi!utcsri!geac!itcyyz!yrloc!intern
- From: eem@ipsaint.ipsa.reuter.COM (Mcdonnell, Eugene E.)
- Subject: More efficient combinations verb
- Message-ID: <1992Dec27.212123.29935@yrloc.ipsa.reuter.COM>
- Sender: intern@yrloc.ipsa.reuter.COM (Intern via QUADRAM)
- Reply-To: eem@ipsaint.ipsa.reuter.COM (Mcdonnell, Eugene E.)
- Organization: Reuters Information Services (Canada)
- Date: 27 Dec 92 21:00:03 UT
- Lines: 46
-
-
- -----------Message forwarded from IPSA Mailbox-------------
-
-
- no. 6857150 filed 20.45.47 sun 27 dec 1992
- from eem
- to uclapl
- subj More efficient combinations verb
-
- To Emmett McLean
-
-
- Roger Hui has written a considerably more efficient version of
- comb. A comparison of timings on two cases:
-
- m n m comb n (McLean) m comb n (Hui) m comb1 n (Hui)
- 5 11 7.583333 0.166667 0.166667
- 6 12 89.18333 0.5 0.583333
-
- Hui's recursive comb is defined as follows:
-
- start =. i.@-.-
- count =. <:@[ ! <:@[ + |.@start
- index =. ;@:((i.-])&.>)
- recur =. (count#start) ,. (index@count{comb&.<:)
- test =. *@[ *. <
- basis =. i.@(<: , [)
- comb =. basis`recur @. test
-
- He points out that the recursion can be replaced by using power
- (^:), and that m comb1 n is also grow^:m m seed n.
-
- seed =. *@[ i.@{ 1 0&,:@(,&1)@>:@(-~)
- em =. >:@{:@$
- en =. 2&+@{:@{:
- g =. em (count#start) en
- h =. em (index@count) en
- grow =. g ,. h { >:
- comb1 =. [ grow@]^:(>{:@$) seed
-
-
- -----------------------------------------------------------
- This posting is forwarded from an internal Reuters mailbox.
- No statement or opinion contained herein should be taken as
- being Reuters policy, or even as being approved by Reuters,
- in any way.
-