octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #63962] perms - Performance - Usage of native


From: Nicholas Jankowski
Subject: [Octave-bug-tracker] [bug #63962] perms - Performance - Usage of native C++ algorithm helpful
Date: Mon, 27 Mar 2023 11:21:22 -0400 (EDT)

Follow-up Comment #10, bug #63962 (project octave):

(now seeing some older discussions about perms ordering, and the wisdom of
trying to follow undocumented matlab...) Older versions of the Matlab doc
(<2005) didn't make any claims about ordering. Sometime later while the output
from matlab never changed, the statement i quoted below about "in reverse
lexicographic order" appeared in the public docs.  looking at the results of
perms with different input ordering, i'm not quite sure how they define
'reverse lexicographical ordering.:


>> perms(1:4)

ans =

     4     3     2     1
     4     3     1     2
     4     2     3     1
     4     2     1     3
     4     1     3     2
     4     1     2     3
     3     4     2     1
     3     4     1     2
     3     2     4     1
     3     2     1     4
     3     1     4     2
     3     1     2     4
     2     4     3     1
     2     4     1     3
     2     3     4     1
     2     3     1     4
     2     1     4     3
     2     1     3     4
     1     4     3     2
     1     4     2     3
     1     3     4     2
     1     3     2     4
     1     2     4     3
     1     2     3     4

>> perms([2 3 1 4])

ans =

     4     1     3     2
     4     1     2     3
     4     3     1     2
     4     3     2     1
     4     2     1     3
     4     2     3     1
     1     4     3     2
     1     4     2     3
     1     3     4     2
     1     3     2     4
     1     2     4     3
     1     2     3     4
     3     4     1     2
     3     4     2     1
     3     1     4     2
     3     1     2     4
     3     2     4     1
     3     2     1     4
     2     4     1     3
     2     4     3     1
     2     1     4     3
     2     1     3     4
     2     3     4     1
     2     3     1     4

>> perms([4 3 2 1])

ans =

     1     2     3     4
     1     2     4     3
     1     3     2     4
     1     3     4     2
     1     4     2     3
     1     4     3     2
     2     1     3     4
     2     1     4     3
     2     3     1     4
     2     3     4     1
     2     4     1     3
     2     4     3     1
     3     1     2     4
     3     1     4     2
     3     2     1     4
     3     2     4     1
     3     4     1     2
     3     4     2     1
     4     1     2     3
     4     1     3     2
     4     2     1     3
     4     2     3     1
     4     3     1     2
     4     3     2     1


other than 'the inputs vector is always last, and you can watch the
permutation flips progress upward starting from the rightmost value', I think
the only real 'rule' is "if your inputs starts sorted lowest to highest, your
output will be in reverse lexicographical order"


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?63962>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]