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

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

[Octave-bug-tracker] [bug #60265] Negative zeros in matrices - inconsist


From: Rik
Subject: [Octave-bug-tracker] [bug #60265] Negative zeros in matrices - inconsistency
Date: Sun, 21 Mar 2021 11:24:44 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36

Update of bug #60265 (project octave):

                Category:                    None => Interpreter            
                  Status:               Need Info => Wont Fix               
             Open/Closed:                    Open => Closed                 

    _______________________________________________________

Follow-up Comment #2:

This is expected and comes up from time to time.  Octave/Matlab are computer
aids for performing numerical calculations, not pure math.  In pure math there
is only one representation of zero.  But, as it happens, the IEEE standard for
floating point numbers uses one bit for the sign and the rest for the
magnitude of a number.  Thus, it is possible to have a magnitude of zero, and
still have either a positive or negative sign bit.

Matlab is the same way.  They don't display the negative sign, but they
remember it.  For example,


A = eye (2)
A = 2x2
    1   0
    0   1

1 ./ -A
ans = 2x2
      -1   -Inf
      -Inf -1


As @Markus mentioned, Octave has a special diagonal matrix class that behaves
like sparse matrices which don't record the sign bit of zeros.  Because they
don't care about sign, they will always return +Inf for 1/0.

So, it's really up to you whether you care about this and, if you do, which
convention you want to adhere to.  If you want behavior more similar to pure
math with only one, positive zero then continue to use diagonal matrices.  If
you want the reverse convention, then disable diagonal matrices with


disable_diagonal_matrix (true)







    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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