Here are the integers represented by these 10 binary numbers.

bitcomb=: 13 :'(x=+/"1 #:i.2^y)#"2#:i.2^y'
   
   
   3 bitcomb 5
0 0 1 1 1
0 1 0 1 1
0 1 1 0 1
0 1 1 1 0
1 0 0 1 1
1 0 1 0 1
1 0 1 1 0
1 1 0 0 1
1 1 0 1 0
1 1 1 0 0
   
  
   #.3 bitcomb 5
7 11 13 14 19 21 22 25 26 28

Linda



   

-----Original Message-----
From: Programming [mailto:[email protected]] On Behalf 
Of Linda Alvord
Sent: Saturday, November 11, 2017 4:49 AM
To: [email protected]
Subject: Re: [Jprogramming] K-sets - bitmap representation of sets. WAS: 
Partitions

Also since tacit has been an issue:

bitcomb
([ = [: +/"1 [: #: [: i. 2 ^ ]) #"2 [: #: [: i. 2 ^ ]
   
Linda

-----Original Message-----
From: Programming [mailto:[email protected]] On Behalf 
Of 'Mike Day' via Programming
Sent: Friday, November 10, 2017 11:28 AM
To: [email protected]
Subject: Re: [Jprogramming] K-sets - bitmap representation of sets. WAS: 
Partitions

Nice.  Note that d doesn't need to be global.
The 63 bit (or 31 for older hardware) limit shouldn't be a problem in practice?!

Wondering if it was possible to avoid boxing,  I've found this version - not 
faster, though more parsimonious in space,  so probably not for serious use:

combbitub =: 4 : 0

assert y<:<:##:_1 (32 b.) 1

lshift =.33 b.

or =.23 b.

k =. (y->:ix =. i.>:d=.y-x)lshift 1

z =. ,0

l =. 1#~ #k NB. "box-sizes" as successively 1s, i.#k, triangular nums etc.

for. i.x do.

nz =. _1 lshift z

z =. nz or {.k

for_j. }. i.#k do. NB. tack on the smaller "boxes"

z =. z, (j{k) or (-j{l) {. nz

end.

l =. +/\. l NB. bump up the box sizes

end.

#: z

)

3 (combbit -: combbitub) 5

1

Cheers,

Mike



10/11/2017 11:46, Erling Hellenäs wrote:

> Hi all!
>
> Bitmap version of comb. Unfortunately handles sets of max 63 items.
>
> I tried to make a general version, but hit the problem with #: .
>
>    ts'5 combbit 10'
> 3.37831e_5 20864
>    ts'5 combbool 10'
> 3.89148e_5 22400
>    ts'5 combREBoss 10'
> 5.51649e_5 44416
>    ts'5 comb 10'
> 3.76319e_5 50944
>
>    ts'13 combbit 26'
> 0.44835 8.03039e8
>    ts'13 combbool 26'
> 0.880373 1.4314e9
>    ts'13 combREBoss 26'
> 2.39319 4.22297e9
>    ts'13 comb 26'
> 2.59969 4.41693e9
>
>    ts'60 combbit 63'
> 0.00416474 5.26221e6
>    ts'60 combbool 63'
> 0.0534253 1.73281e7
>    ts'60 combREBoss 63'
> 0.0344776 6.81943e7
>    ts'60 comb 63'
> 0.310994 1.38554e8
>
> combbit=: 4 : 0
> assert y<:<:##:_1 (32 b.) 1
> lshift=.33 b.
> or=.23 b.
> k=.<"0 (y->:i.>:d=:y-x)lshift 1
> z=. (d$<i.0),<0
> for. i.x do. z=. k (or)&.> ,&.>/\. (_1&lshift)&.> z end.
> #: ;z
> )
>
> Cheers,
>
> Erling Hellenäs
>
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to