What you should be looking at are combinations instead of permutations,
because what you are computing are all the different ways of choosing +/b
1s (or +/~b 0s) from i.#b.  For example:

   b=: 1 1 1 0 0
   (i.#b) e."1 (+/b) comb #b
1 1 1 0 0
1 1 0 1 0
1 1 0 0 1
1 0 1 1 0
1 0 1 0 1
1 0 0 1 1
0 1 1 1 0
0 1 1 0 1
0 1 0 1 1
0 0 1 1 1

comb is from the for. page of the dictionary.
http://www.jsoftware.com/help/dictionary/cfor.htm



On Sun, May 29, 2016 at 2:12 PM, Louis de Forcrand <[email protected]> wrote:

> Is there a faster (and relatively concise) way of generating
> (~.@:A.~ i.@!@#) b
> where b is a logical vector (of 0s and 1s)?
> There are obviously (+/ ! #) b vectors in the result, but I can't
> see any relation in their anagram indices:
>
>    I.@(-:"1/~ ~.)@(A. ~i.@!@#) 1 1 1 0 0
>  0  1  6  7 24 25  30  31  48  49  54  55
>  2  4  8 10 26 28  32  34  50  52  56  58
>  3  5  9 11 27 29  33  35  51  53  57  59
> 12 14 18 20 36 38  42  44  60  62  66  68
> 13 15 19 21 37 39  43  45  61  63  67  69
> 16 17 22 23 40 41  46  47  64  65  70  71
> 72 74 78 80 84 86  96  98 102 104 108 110
> 73 75 79 81 85 87  97  99 103 105 109 111
> 76 77 82 83 88 89 100 101 106 107 112 113
> 90 91 92 93 94 95 114 115 116 117 118 119
>
> The (< I , J )&{ of this table corresponds to the Jth occurence
> of the Ith unique permutation of the vector in its table of all
> possible permutations.
>
> Thanks,
> Louis
>
> ----------------------------------------------------------------------
> 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