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: Fri, 31 Mar 2023 16:06:18 -0400 (EDT)

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

still recompiling to test, but looking through the BISTs for the new perms,
some don't seem to be matching the compatible ordering.

lexicographical ordering basically results in the sorted number increasing at
each step. so the reverse of that has the lowest number at the bottom, highest
at the top.

e.g., 


>> perms([1 2])
ans =

     2     1
     1     2

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

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


the new behavior means that pattern should be matched based on input order,
not input values. e.g.:

%!assert (perms ([pi, e]), [pi, e; e, pi])

should be changed to:

%!assert (perms ([pi, e]), [e, pi; pi, e])

similarly, the point of the reopened report is that 

perms(1:5) and perms ([2 5 4 1 3]) shouldn't give the same result, so %!assert
(perms (1:5), perms ([2 5 4 1 3]'))

should no longer pass. what they should produce:


>> a = perms(1:5);
>> a(end-10:end,:)

ans =

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

>> a = perms([2 5 4 1 3]);
>> a(end-10:end,:)

ans =

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




    _______________________________________________________

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]