bugGNU Octave - Bugs: bug #29628, assignment of logical argument is...

 
 

bug #29628: assignment of logical argument is broken

Submitter:  None
Submitted:  Wed 21 Apr 2010 02:46:24 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  highegg
Originator Name:  Alois Schlögl Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 23 Apr 2010 09:24:19 AM UTC, comment #2: 
Jaroslav Hajek <highegg>
Wed 21 Apr 2010 04:57:12 PM UTC, comment #1: 

This is confirmed on a recent hg tip (fdf28dae0f37, Apr 20th:2010)

Assignments using a null selection have trouble when the rhs side is not of type double.

For example,
-----------------------------------
octave:1> x([]) = single(1)
x = [](0x0)
octave:2> whos
Variables in the current scope:

  Attr Name        Size                     Bytes  Class
  ==== ====        ====                     =====  =====
       ans         1x13                       111  cell
       x           0x0                          0  double

Total is 13 elements using 111 bytes
-----------------------------------

This correctly sets x to [] but fails to set the class correctly to single.

----------------------------------
octave:7> clear x
octave:8> x([]) = logical(1)
x = 0
octave:9> whos
Variables in the current scope:

  Attr Name        Size                     Bytes  Class
  ==== ====        ====                     =====  =====
       ans         1x13                       111  cell
       x           1x1                          1  logical

Total is 14 elements using 112 bytes

----------------------------------

This correctly sets the class to logical but does not initialize the value of x to the null array.

----------------------------------
octave:10> clear x
octave:11> x([]) = char("A")
x =
octave:12> whos
Variables in the current scope:

  Attr Name        Size                     Bytes  Class
  ==== ====        ====                     =====  =====
       ans         1x13                       111  cell
       x           0x0                          0  char

Total is 13 elements using 111 bytes

-----------------------------------

The operator seems to work correctly for the char datatype.

It appears 'single' and 'logical' need some work.

Rik <rik5>
Group administrator
Wed 21 Apr 2010 02:46:24 PM UTC, original submission:  



The assignment to a vector with an empty index list

   clear x
   x([]) = 0

yields an empty result, which is correct.

   x = [](0x0)


However, if the rhs-value is of type logical

   clear x
   x([]) = logical(0)

the result is a scalar, which is incorrect. 
  
    x = 0

This behaviour is inconsistent. Moreover, it breaks also the following command:

   x=repmat(logical(0),0,1)

error: reshape: can't reshape 1x1 array to 0x1 array
error: called from:
error:   /usr/local/share/octave/3.3.51+/m/general/repmat.m at line 64, column 7


The behavior is observed on 3.2.2 and the 3.3.51+ compiled in the last two days.




Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by highegg (Updated the item)
  • -email is unavailable- added by rik5 (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-04-23 highegg StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2010-04-23 highegg Assigned toNone highegg
    2010-04-21 rik5 StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code