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

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

[Octave-bug-tracker] [bug #62485] sort does not sort


From: Michael Leitner
Subject: [Octave-bug-tracker] [bug #62485] sort does not sort
Date: Wed, 18 May 2022 03:47:26 -0400 (EDT)

Follow-up Comment #2, bug #62485 (project octave):

Depending on your point of view, this is a Matlab incompatibility feature or
bug (to me, the latter). For context see the discussion in bug #52919 and bug
#53013. 

Markus: you can define an order on any set, any order you like. In this sense,
any set is orderable. The point is only that the complex numbers as a field,
that is, a set together with two binary operations fulfilling some conditions,
in the specific case addition and multiplication, cannot be equipped with an
order relation that is compatible with the field operations. In this sense the
complex numbers cannot be made to be an ordered field. Octave compares on the
absolute value, therefore complex multiplication is compatible with ordering:
if a<=b then a*c<=b*c for any a, b and c (also complex). Matlab does it
differently, it sorts on the real part, and therefore addition is compatible
with ordering: if a<=b then a+c<=b+c for any a, b and c. 

This is the reason for the OP's observation (as octave's sorting behaviour
follows from its comparison operators). I maintain that I would be in favour
of switching to matlab's definition of complex order, potentially augmented by
comparing the imaginary entries for tied real entries, which would solve a
number of issues mentioned in above-quoted discussions. Matlab's sort since
r2017a has an option to allow to specify the comparison method, while by
default it still compares on the magnitude. If octave makes the switch in the
relation operators, the default behaviour of sort and friends, and max and
friends, and in addition implements Matlab's arguments for the comparison
method in sort and max, it is consistent within itself and compatible with
matlab in anything but the default method used in sort (but matlab-compatible
behaviour could be specified), while now it is incompatible in the relation
operators and max. 


    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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