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

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

[Octave-bug-tracker] [bug #58215] sparse multiplication with Inf


From: Rik
Subject: [Octave-bug-tracker] [bug #58215] sparse multiplication with Inf
Date: Mon, 20 Apr 2020 13:36:01 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko

Update of bug #58215 (project octave):

                  Status:                    None => Confirmed              

    _______________________________________________________

Follow-up Comment #4:

See bug #36562 from 2012 which involves sparse storage interacting with NaN. 
In general, the IEEE special values (-Inf, +Inf, NaN) behave differently in
Octave depending on whether the matrix is full or sparse.

I wrote up some comments there a long time ago.  This is fixable, and probably
should be, but it will significantly change the way sparse matrix
multiplication gets handled.  Currently, multiplication only takes place
between the set of matrix elements which are both non-zero, because the code
assumes that 0 multiplied by any other value is still zero.


0 * x == 0 for all x


This is a valid statement in pure math, but not in the IEEE system used to
represent numbers.  In this case, the following holds


0 * x == 0 for all normal numerical values of x
0 * Inf == NaN
0 * -Inf == NaN
0 * NaN == NaN


To see what I mean


octave:1> x = sparse ([1, 0]);
octave:2> y = sparse ([0, NaN]);
octave:3> x + y
ans =

Compressed Column Sparse (rows = 1, cols = 2, nnz = 2 [100%])

  (1, 1) -> 1
  (1, 2) -> NaN

octave:4> x .* y
ans =

Compressed Column Sparse (rows = 1, cols = 2, nnz = 0 [0%])


octave:5> z = sparse ([0, Inf]);
octave:6> x .* z
ans =

Compressed Column Sparse (rows = 1, cols = 2, nnz = 0 [0%])



Roughly, the operation in Octave is


z = x .* y => 
idx1 = find (x);   # Find non-zeros in x
idx2 = find (y);   # Find non-zeros in y
idx3 = intersect (idx1, idx2);
z = zeros (size (x));
z(idx) = x(idx) .* y(idx);




    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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