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

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

[Octave-bug-tracker] [bug #65423] Sort order is wrong for real numbers


From: anonymous
Subject: [Octave-bug-tracker] [bug #65423] Sort order is wrong for real numbers
Date: Wed, 6 Mar 2024 12:00:00 -0500 (EST)

URL:
  <https://savannah.gnu.org/bugs/?65423>

                 Summary: Sort order is wrong for real numbers
                   Group: GNU Octave
               Submitter: None
               Submitted: Wed 06 Mar 2024 05:00:00 PM UTC
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
                 Release: 9.0.90
         Discussion Lock: Any
        Operating System: Any
           Fixed Release: None
         Planned Release: None


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Wed 06 Mar 2024 05:00:00 PM UTC By: Anonymous
Define this matrix:

>> A = [-i 1 i; -i i -1; 1 1 1; 1 -1-i -1+i; -1 1 1; -1 -1 1; -1 -1 -1; -1 1-i
1+i]
A =
   0 - 1i   1 + 0i   0 + 1i
   0 - 1i   0 + 1i  -1 + 0i
   1 + 0i   1 + 0i   1 + 0i
   1 + 0i  -1 - 1i  -1 + 1i
  -1 + 0i   1 + 0i   1 + 0i
  -1 + 0i  -1 + 0i   1 + 0i
  -1 + 0i  -1 + 0i  -1 + 0i
  -1 + 0i   1 - 1i   1 + 1i


Sort each row:

>> B = sort (A, 2)
B =
   0 - 1i   1 + 0i   0 + 1i
   0 - 1i   0 + 1i  -1 + 0i
   1 + 0i   1 + 0i   1 + 0i
   1 + 0i  -1 - 1i  -1 + 1i
   1 + 0i   1 + 0i  -1 + 0i
   1 + 0i  -1 + 0i  -1 + 0i
  -1 + 0i  -1 + 0i  -1 + 0i
  -1 + 0i   1 - 1i   1 + 1i


The 5me and 6me rows are sorted in the wrong order. To check:

Find rows of A that are not already sorted:

>>  u = A (any (B ~= A, 2), :)
u =
  -1   1   1
  -1  -1   1


But those rows are already sorted!

>>  u == sort (u, 2)
ans =
  1  1  1
  1  1  1


To check, sort one row at a time:

for i = 1:size(A,1)
  C(i, :) = sort (A(i, :));
end

C == B


The result is that C and B do not equal, but they should.

Each row of A should be sorted independently of other rows with "B = sort (A,
2)". But they are not.








    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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