bugGNU Octave - Bugs: bug #52174, bitand, bitor, bitxor: support...

 
 

bug #52174: bitand, bitor, bitxor: support automatic broadcasting

Submitter:  sebman <sebma>
Submitted:  Thu 05 Oct 2017 11:05:30 AM UTC
   
 
Category:  Octave Function Severity:  2 - Minor
Priority:  3 - Low Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 23 Oct 2020 04:35:15 PM UTC, comment #3: 

For someone who might be interested in fixing this: The place where you should probably start looking is the function "bitopxx" in bitfcns.cc:
https://hg.savannah.gnu.org/hgweb/octave/file/9c3f4e9a0c83/libinterp/corefcn/bitfcns.cc#l81

Markus Mützel <mmuetzel>
Group administrator
Thu 22 Oct 2020 07:26:58 PM UTC, comment #2: 

Requesting an increase in priority as this Matlab incompatibility has been present for 3 years now.

Is it OK to use a wrapper called bitxor.m that simply calls bsxfun and the internal bitxor? If so, how to force the call to the internal bitxor from bitxor.m instead of simply calling itself infinitely?

Anonymous
Thu 05 Oct 2017 03:45:08 PM UTC, comment #1: 

This was a recent change in Matlab R2016b, take a look at https://blogs.mathworks.com/loren/2016/10/24/matlab-arithmetic-expands-in-r2016b/

The bitand, bitor, and bitxor functions are among a handful of others that now support automatic broadcasting when given unlike vectors.

As a workaround for now you can still explicitly use bsxfun


c = bsxfun (@bitxor, byteVector', data);


Mike Miller <mtmiller>
Group Member
Thu 05 Oct 2017 11:05:30 AM UTC, original submission:  

Hi,

First I have one question, why not migrate to GitHub or other ?
It would be great to be able to use markdown language and preview the bug before we submit it.

Here is the problem with the bitxor function :

On Matlab R2017a (9.2.0.556344) :

>> byteVector=0:255;
>> data=0:499;
>> whos byteVector data

  Name            Size             Bytes  Class     Attributes

  byteVector      1x256             2048  double
  data            1x500             4000  double

>> c=bitxor(byteVector,data);

Error using bitxor
Inputs must have the same size.

>> c=bitxor(byteVector',data); %Transposing the first vector
>> whos c

  Name        Size               Bytes  Class     Attributes

  c         256x500            1024000  double
On Octave 4.2.1 :
octave:1> byteVector=0:255;
octave:2> data=0:499;
octave:3> whos byteVector data
Variables in the current scope:

   Attr Name            Size                     Bytes  Class
   ==== ====            ====                     =====  =====
        byteVector      1x256                       24  double
        data            1x500                       24  double

Total is 756 elements using 48 bytes

octave:4> c=bitxor(byteVector,data);
error: bitxor: size of X and Y must match, or one operand must be a scalar
octave:4> c=bitxor(byteVector',data); %Transposing the first vector
error: bitxor: size of X and Y must match, or one operand must be a scalar
octave:4> whos c
octave:5>

Can you please have a look ?

sebman <sebma>

 

(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 mmuetzel (Posted a comment)
  • -email is unavailable- added by sebma (Submitted the item)
  • -email is unavailable- added by sebma
  •  

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

    Date Changed by Updated Field Previous Value => Replaced by
    2020-11-19 mtmiller Carbon-CopyRemoved 80942 -
    2020-10-23 mmuetzel Operating SystemMac OS Any
    2017-10-05 mtmiller Severity3 - Normal 2 - Minor
        Priority5 - Normal 3 - Low
        Item GroupIncorrect Result Matlab Compatibility
        StatusNone Confirmed
        Release4.2.1 dev
        Summarybitxor does not work between one row vector and one column vector bitand, bitor, bitxor: support automatic broadcasting
    2017-10-05 sebma Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code