Jon Perry on Wed, 16 Oct 2002 18:11:45 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
numtoperm |
3.2.33 numtoperm(n; k): generates the k-th permutation (as a row vector of length n) of the numbers 1 to n. The number k is taken modulo n! , i.e. inverse function of permtonum. numtoperm(5,0) returns [5,4,3,2,1] which is the k-th permutation of n to 1. Also, how is this function defined, as: ? alias(np,numtoperm) ? np(5,0) %3 = [5, 4, 3, 2, 1] ? np(5,1) %2 = [5, 4, 3, 1, 2] ? np(5,2) %4 = [5, 4, 2, 3, 1] ? np(5,3) %5 = [5, 4, 1, 3, 2] ? np(5,4) %6 = [5, 4, 2, 1, 3] ? np(5,5) %7 = [5, 4, 1, 2, 3] seems erratic. Surely an alphabetic ordering is preferable? See http://www.users.globalnet.co.uk/~perry/maths/fld/fld.htm for inspiration, etc... Jon Perry perry@globalnet.co.uk http://www.users.globalnet.co.uk/~perry/maths BrainBench MVP for HTML and JavaScript http://www.brainbench.com