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

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

[Octave-bug-tracker] [bug #55445] (minor) Boolean matrix sometimes becom


From: Dave Goel
Subject: [Octave-bug-tracker] [bug #55445] (minor) Boolean matrix sometimes becomes double upon assigning zeros:
Date: Fri, 11 Jan 2019 07:07:39 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36

URL:
  <https://savannah.gnu.org/bugs/?55445>

                 Summary: (minor) Boolean matrix sometimes becomes double upon
assigning zeros:
                 Project: GNU Octave
            Submitted by: deego
            Submitted on: Fri 11 Jan 2019 12:07:37 PM UTC
                Category: Interpreter
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Other
                  Status: None
             Assigned to: None
         Originator Name: deego
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 4.2.2
        Operating System: GNU/Linux

    _______________________________________________________

Details:


Normally, if I boolmatrix(indices)=0, octave infers that I really meant false
when I said 0, and it keeps the matrix boolean.  You may now go on do things
like bar(boolmatrix)=k,  and assume that octave will do a (faster version) of
bar(find(boolmatrix))=k.  

But, this fails for some edge cases, leading to (hard-to-track!) bugs: 

Example,

b = [false false] 
b(indices)=0 ## where indices are [], [1], [2], [1 2], etc. 
class (b)  ## => logical


b = [false] 
b(indices)=0  ## for any choice of indices: [], [1]
class (b)  ## => double

Finally, if b were an empty bool matrix, it continues to stay bool matrix. The
problem seems to be limited to the 1-element case. 

----

A similar switch doesn't seem to happen if I assign a(1)=<double> where a is a
uint8 matrix with only one element, and a stays uint8.

----

(I should learn to stop using 0/1 for false/true).






    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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