bugGNU Octave - Bugs: bug #33219, logical() function does not accept...

 
 

bug #33219: logical() function does not accept integer input scalars

Submitter:  None
Submitted:  Tue 03 May 2011 02:19:11 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Performance
Status:  Fixed Assigned to:  None
Originator Name:  Jochen Weber Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.4.0
Operating System:  * Mac OS Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 04 May 2011 06:20:53 PM UTC, comment #8: 

I checked in the following change on the stable branch:

http://hg.savannah.gnu.org/hgweb/octave/rev/d3ccd2e37de6

John W. Eaton <jwe>
Group administrator
Wed 04 May 2011 04:49:55 PM UTC, comment #7: 

I've changed the title again to reflect all integer scalars, not just unsigned, are affected.

This is the third recent bug report where array operations work correctly, but scalar operations do not.  See, for example, bug #33197 with sortrows on a scalar and bug #33218 with transpose on scalar structs

Rik <rik5>
Group administrator
Wed 04 May 2011 04:38:04 PM UTC, comment #6: 

Yes, indeed, it's only for scalars (but then again, I put that in the title of the bug report ;)

/jochen

Jochen Weber <jweber>
Wed 04 May 2011 04:11:20 PM UTC, comment #5: 

I think it's almost narrowed down.  I believe the problem is only with scalar values, not array values.  Could Jordi or Jochen verify that the following works:


logical (uint32([5 5]))

but the scalar example fails
logical (uint32([5]))


Rik <rik5>
Group administrator
Wed 04 May 2011 11:54:48 AM UTC, comment #4: 

No, it's not a platform-dependent issue. I'm able to confirm on Debian that Jochen's "logical(uint32(5))" example errors out.

Jordi GutiƩrrez Hermoso <jordigh>
Group Member
Wed 04 May 2011 04:52:43 AM UTC, comment #3: 

I modified the summary field to have the dependency on MacOS.  Hopefully one of the other developers who use the MacOS platform will be able to help.  For reference, this works correctly on a Linux system (Kubuntu 10.04).

Rik <rik5>
Group administrator
Wed 04 May 2011 02:30:32 AM UTC, comment #2: 

This might be a platform dependent bug?

On my Octave 3.4.0 on Mac OSX I get:


octave-3.4.0:1> logical(uint32(1))
error: octave_base_value::bool_value(): wrong type argument `uint32 scalar'


Jochen Weber <jweber>
Wed 04 May 2011 01:46:58 AM UTC, comment #1: 

I think there may be a different issue here.  The following code shows logical() working correctly on uint32 arrays.


x = uint32([-2 0 1 2]);
class (x)
  ans = uint32
logical (x)
y = logical (x)
y =

   0   0   1   1
class (y)
  ans = logical


Perhaps you could post the file that, when read, is causing the problem and also the exact bit of code which reproduces the error.

Rik <rik5>
Group administrator
Tue 03 May 2011 02:19:11 PM UTC, original submission:  

Given that I'm writing code that reads/writes diverse file formats, some of them contain parameter values stored as 32-bit (unsigned) integers, which yet can only ever have values 0 (false) and 1 (true), which I then internally want to handle as such (logical value).

Matlab accepts the following syntax, which fails in Octave:


filevalue = fread(fid, [1, 1], '*uint32');
storevalue = logical(filevalue);


A workaround is simple (but definitely seems run-time inefficient on first glance):


filevalue = fread(fid, [1, 1], '*uint32');
storevalue = logical(double(filevalue));


or alternatively (not tested, but guessing this works also)


filevalue = fread(fid, [1, 1], 'uint32=>double');
storevalue = logical(filevalue);


Given that I use a function that interprets a text file containing the information about the parameters to read/write from/to each file (depending on the file format), I definitely wouldn't want to use the second construction as my general syntax, as this would potentially require a large amount of extra memory in case the read content is a large array of type uint8 or so.

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 jwe (Posted a comment)
  • -email is unavailable- added by jordigh (Posted a comment)
  • -email is unavailable- added by jweber (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-05-04 jwe StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2011-05-04 rik5 Summarylogical() function does not accept unsigned integer input scalars logical() function does not accept integer input scalars
    2011-05-04 rik5 StatusNeed Info Confirmed
    2011-05-04 jordigh Summarylogical() function does not accept (unsigned) integer input on MacOS logical() function does not accept unsigned integer input scalars
    2011-05-04 rik5 Summarylogical() function does not accept (unsigned) integer input logical() function does not accept (unsigned) integer input on MacOS
    2011-05-04 rik5 StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code