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

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

[Octave-bug-tracker] [bug #50426] perms() sort order different than Matl


From: Nicholas Jankowski
Subject: [Octave-bug-tracker] [bug #50426] perms() sort order different than Matlab
Date: Mon, 27 Mar 2023 12:39:22 -0400 (EDT)

Follow-up Comment #17, bug #50426 (project octave):

A recent discussion over on bug #63962 about perms sort ordering indicated
that the fix implemented by this report isn't actually matlab compatible.

as laid out in comment #11, after initial sorting issues, matlab's perms is
'now sorting as expected' and as documented.  However, it appears that when
Matlab says "sorts in reverse lexicographic order" they are referring to the
position order not the element value ordering.  (or lexicographical set
ordering).  hence in matlab 2022b:


>> perms([1 2 3])
ans =
     3     2     1
     3     1     2
     2     3     1
     2     1     3
     1     3     2
     1     2     3

>> perms([2 1 3])
ans =
     3     1     2
     3     2     1
     1     3     2
     1     2     3
     2     3     1
     2     1     3


while in octave 8.1.0:


>> perms([1 2 3])
ans =

   3   2   1
   3   1   2
   2   3   1
   2   1   3
   1   3   2
   1   2   3

>> perms([2 1 3])
ans =

   3   2   1
   3   1   2
   2   3   1
   2   1   3
   1   3   2
   1   2   3


Since this is the matlab behavior after they fixed the original ordering bug
7-8 years ago, and i don't see any other outstanding bugs for perms, I assume
they consider this the 'correct' ordering behavior.  The matlab ordering is
consistent with lexicographical set ordering if you just consider any input is
actually just 1:N.  Of course their help currently gives minimal explanation
and their examples all have sorted inputs.  

worth reopening and revisiting an efficient way of getting compatible
ordering?


    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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