bugGNU Octave - Bugs: bug #51196, plus, +, minus, - on column vs row...

 
 

bug #51196: plus, +, minus, - on column vs row vectors should fail but returns matrix

Submitter:  Doug McLelland <weedoug>
Submitted:  Wed 07 Jun 2017 08:51:35 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Missed Error or Warning
Status:  Duplicate Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 4.2.1 Operating System:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 07 Jun 2017 10:21:41 AM UTC, comment #1: 

Hi,

This is called broadcasting and is actually intensional. This used to be an Octave extension but AFAIU the most recent versions of Matlab do the same.

There used to be a warning (which could be turned into an error) when this extension was used but it has been removed. See bug #45761 .

Closing report as duplicate.

Pantxo Diribarne <pantxo>
Group Member
Wed 07 Jun 2017 08:51:35 AM UTC, original submission:  

When adding or subtracting a pair of vectors, one column, one row, I expect them to return an error of unequal size (as Matlab does), or at a push, to reshape and add if the vectors are of equal length. Instead I get:


>>test1 = 1:5
test1 =

   1   2   3   4   5

>> test2 = (6:10)'
test2 =

    6
    7
    8
    9
   10

>> test1+test2
ans =

    7    8    9   10   11
    8    9   10   11   12
    9   10   11   12   13
   10   11   12   13   14
   11   12   13   14   15


In this example, the vectors are of equal length, but a similar result is obtained for unequal vectors.

I think this is very unlikely to be intentional? And dangerous, since it can go completely unnoticed and result in serious errors if you then go on to use the output referring by index.

Doug McLelland <weedoug>

 

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

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

    Date Changed by Updated Field Previous Value => Replaced by
    2017-06-07 pantxo StatusNone Duplicate
        Open/ClosedOpen Closed
    2017-06-07 weedoug Carbon-Copy- Added weedoug

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code