|Bill Allombert on Wed, 10 Oct 2012 16:47:18 +0200|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
|Re: numtoperm abd Factorial Number System|
On Sat, Oct 06, 2012 at 07:56:13PM -0400, Mathieu Carbou wrote: > I was wondering why in PARI the numtoperm does not match the Nth > permutation in the factorial number system ? > > Is there a way to use numtoperm to get the good result or I have to code > a function which decompose the number in the factorial number system by > myself ? You can use this mynumtoperm(n,a)=Vec(Vecsmall(numtoperm(n,a))^-1*vectorsmall(n,i,n+1-i)) mypermtonum(p)=permtonum(Vec(vectorsmall(#p,i,#p+1-i)*Vecsmall(p)^-1)) ? for(i=0,5,print(mynumtoperm(3,i))) [1,2,3] [1,3,2] [2,1,3] [2,3,1] [3,1,2] [3,2,1] Cheers, Bill.