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

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

[Octave-bug-tracker] [bug #60859] sparse matrix problem with float


From: Rik
Subject: [Octave-bug-tracker] [bug #60859] sparse matrix problem with float
Date: Thu, 1 Jul 2021 14:02:51 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Safari/537.36

Update of bug #60859 (project octave):

                  Status:          Ready For Test => Need Info              

    _______________________________________________________

Follow-up Comment #2:

This is expected.  Sparse matrices are only implemented for double values.

Is the expectation that the single value will be automatically converted to
double?  This is what Matlab does, but I don't like that it does it without
any sort of warning.

The normal rules for mathematical operations are that the result type is most
restrictive possible.  So when combining singles with doubles the result is of
type single.  And when combining integers with floating point the result is of
type integer.


octave:5> x = double (1)
x = 1
octave:6> class (x)
ans = double
octave:7> x = x + single (2)
x = 3
octave:8> class (x)
ans = single
octave:9> x = x + uint8 (3)
x = 6
octave:10> class (x)
ans = uint8


Neither Matlab nor Octave allow the creation of a single sparse matrices.  It
seems to me that an error is appropriate.  This forces the programmer to add a
call to double() around the assigned value thereby reminding them that
calculations will occur with doubles going forward.


    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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