The similarity to A. is that
A. 2 3 1 0 is relative to 0 1 2 3
A. 2 3 1 0
17
17 A. 0 1 2 3
2 3 1 0
so,
permN 2 2 1 011
will have reverse F
11 F 0 1 2 2 NB. 0 1 2 2 is sorted version of original
2 2 1 0
11 F 0 1 1 2
2 1 1 0
----- Original Message -----
From: Raul Miller <[email protected]>
To: Programming forum <[email protected]>
Sent: Thursday, May 5, 2016 9:44 PM
Subject: Re: [Jprogramming] permutation and combination numbers (with repeat)
A. allows adding a constant to the vector, and it allows preceding the
vector with (,~ (-.~ i.@(>./))), and any suffix of that which does not
eliminate the original values of the vector. (And, where the vector
can be formed using either of these mechanisms, it also allows
dropping certain prefixes of the vector.)
But when you introduce repetitions, it seems to me that you need to
distinguish between different repetitions of the same values. And, in
some cases you do make that distinction, but in other cases you do
not. So I am trying to understand what it is that is consistent about
your implementation here.
For example, let's consider these:
permN 2 2 1 0
11
permN 2 1 1 0
11
permN 2 1 0 0
11
What is it that's being sorted here?
It does not seem that you are sorting the values:
/: 2 2 1 0
3 2 0 1
/: 2 1 1 0
3 1 2 0
/: 2 1 0 0
2 3 1 0
You might be using downgrade?
\: 2 2 1 0
0 1 2 3
\: 2 1 1 0
0 1 2 3
\: 2 1 0 0
0 1 2 3
But, no, that does not hold for a different example:
\: 0 0 1 0
2 0 1 3
\: 0 1 0 1
1 3 0 2
\: 1 0 1 1
0 2 3 1
permN 0 0 1 0
1
permN 0 1 0 1
1
permN 1 0 1 1
1
Put differently, what does "relative to the sorted permutation (with
repetitions) list of the argument" mean?
A. does not deal with sorted permutations with repetitions, so simply
referencing A. does not actually mean anything to me.
A. 0 0
|index error
Thanks,
--
Raul
On Thu, May 5, 2016 at 7:29 PM, 'Pascal Jasmin' via Programming
<[email protected]> wrote:
> Because its relative to the sorted permutation (with repetitions) list of the
> argument. A. does this as well.
>
>
> A. 1 0
> 1
> A. 0 2 1
> 1
>
>
>
>
> ----- Original Message -----
> From: Raul Miller <[email protected]>
> To: Programming forum <[email protected]>
> Sent: Thursday, May 5, 2016 7:25 PM
> Subject: Re: [Jprogramming] permutation and combination numbers (with repeat)
>
> I am not understanding, still. So let's try a different example:
>
> Why are these equal?
>
> permN 0 0 1 0
> 1
> permN 0 1 0 1
> 1
> permN 1 0 1 1
> 1
>
> Thanks,
>
> --
> Raul
>
> On Thu, May 5, 2016 at 6:20 PM, 'Pascal Jasmin' via Programming
> <[email protected]> wrote:
>> Its relative to the sorted order of the input
>>
>> rp1 =: (] (] <@; $:^:(1<#)@del1~)"1 0 ~.@])
>> untreep =: (({.,"0 1 $:^:(1<L.)@}.)&>)
>> rperm6 =: (a: ;"1@(]#~ -.@e."1) ,&.:(<"1)@:untreep@:rp1)
>>
>> rperm6 0 0 1
>> 0 0 1
>> 0 1 0
>> 1 0 0
>>
>>
>> rperm6 0 1 1
>> 0 1 1
>> 1 0 1
>> 1 1 0
>>
>>
>>
>> in both cases, the 0 index is the sorted order
>>
>> permN 1 0 1
>> 1
>> permN 1 0 0
>> 2
>>
>> the index in their respective permutation lists.
>>
>> ----- Original Message -----
>> From: Raul Miller <[email protected]>
>> To: Programming forum <[email protected]>
>> Sent: Thursday, May 5, 2016 6:13 PM
>> Subject: Re: [Jprogramming] permutation and combination numbers (with repeat)
>>
>> Why are these two results equal?
>>
>> permN 0 0 1
>> 0
>> permN 0 1 1
>> 0
>>
>> Thanks,
>>
>> --
>> Raul
>>
>>
>> On Thu, May 5, 2016 at 5:58 PM, 'Pascal Jasmin' via Programming
>> <[email protected]> wrote:
>>> Some routines to calculate permutation and combination numbers, similar to
>>> A. (but allows permutations with repeat)
>>>
>>> del1 =: i.~ ({. , >:@[ }. ]) ]
>>>
>>> combN =: (0:`((<:@[ - {.@]) $: >:@{.@] -~ }.@])@.(0 < #@]) + 0:`(<:@#@]
>>> +/@:! <:@[ - i.@{.@])@.(0 < {.@]) )
>>>
>>> combNF =: 3 : 'a =. 1 { 0 {:: y label_. (i.a) + +/\ 1 {:: ([ (] ;~ [ - 1
>>> ,~ _2 >:@{ ]) }:@] , {:@] ([ ({.@] ,(- {:)) ] (] , {~) 1 i:~ >:) (0 , ]
>>> (+/\)@:! ( a i.@:-~ [) -~ [)/@:<:@[ )&>/^: (<:a) y'@:;
>>>
>>> permC =: # %&(x:@:(*/))&:! #/.~
>>>
>>> permN1 =: ((0:`( (] - <./)@:({.@] del1 [) $: (] - <./)@:}.@] )@.(1 < #@]))
>>> + (permC % #)@] * [ i. {.@] ) f.
>>>
>>> permN =: /:~ permN1 ]
>>>
>>> 100x combN 15 25 35 45 55 65 85
>>> 11284989655
>>>
>>> 100 7 combNF 11284989655x
>>> 15 25 35 45 55 65 85
>>>
>>> permN 1 0 0 2 1 3 3 1
>>> 434
>>>
>>> haven't done the reverse to permN yet, but these routines combined can be
>>> used to compress any list into 2 numbers (with a key). You can google for
>>> combinatorial number base, and there is A., but not sure A. has been done
>>> for permutations with repeats. Which produces smaller numbers than A. does
>>> (due to fewer underlying permutations).
>>> ----------------------------------------------------------------------
>>> 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
> ----------------------------------------------------------------------
> 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm