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

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

[Octave-bug-tracker] [bug #47415] out of memory negating a permutation m


From: Rik
Subject: [Octave-bug-tracker] [bug #47415] out of memory negating a permutation matrix
Date: Wed, 23 Mar 2016 20:02:42 +0000
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0

Follow-up Comment #19, bug #47415 (project octave):

The numerical error is large only if you define it in reference to Matlab,
rather than in reference to pure math.  In mathematics, 0 is unsigned so 1 /
-0 == Inf.

It seems like we are allowing the details of the implementation (the fact that
the IEEE floating point standard has a signbit separate from the actual
number) to dictate what the result should be rather than looking at the
specification (the rules of mathematics).  Normally, leaking of the
implementation through an API is considered a bad thing as the results may
change wildly based on the underlying implementation. 

I'm going to use Diagonal matrices for examples which have the same issues as
Permutation matrices.  Diagonal, Permutation, and Sparse matrices will all
need to be reviewed after a path forward is chosen.


x = diag ([1 2])
x =

Diagonal Matrix

   1   0
   0   2



That's okay, but now take the negation


y = -x
y =

Diagonal Matrix

  -1   0
   0  -2



This agrees with mathematics and with sparse matrices, but disagrees with
Permutation matrices and Full matrices.

For regular Full matrices,


xd = [1 0; 0 2]
xd =

   1   0
   0   2

yd = -x
yd =

  -1  -0
  -0  -2



But this is implementation dependent.  If the numbers are stored as two's
complement then there is only one zero and the behavior, even for Full
matrices, is inconsistent.


xi = int8 ([1 0; 0 2])
xi =

  1  0
  0  2

yi = -xi
yi =

  -1   0
   0  -2



In quantum mechanics you often get answers that are the same up to an
arbitrary phase factor.  It seems like this is the case here.  The value is
always zero, but the phase factor is +/- 1.  With multiplication, the value is
0 so the result will be be +/- 0.  With division, the value is zero so the
result will be +/- Inf.

I don't think it is unreasonable to have Octave pick the arbitrary phase
factor in a way that it easy for us to understand (just like pure math) or to
code.  If programmers want exact congruence with Matlab then they can pay for
Matlab or disable Octave's special features. 


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?47415>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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