bugGNU Octave - Bugs: bug #45761, Invalid addition of...

 
 

bug #45761: Invalid addition of vectors/matrices with incorrect sizes

Submitter:  None
Submitted:  Fri 14 Aug 2015 02:49:46 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Wont Fix Assigned to:  None
Originator Name:  F. Arnold Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 4.0.0
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 17 Aug 2018 09:39:29 PM UTC, comment #10: 

yes, I'd agree, it can be closed.

However, I still think that it would be great to allow for something like I suggested in comment #6 but I guess jwe, rik and mike are not interested and I do not know Octave's internals well enough...

Seb.

Sebastian <sschoeps>
Wed 15 Aug 2018 03:40:25 PM UTC, comment #9: 

Can this report be closed?  Broadcasting is now on by default in both Octave and Matlab and is simply the way the language operates.

Rik <rik5>
Group administrator
Sat 01 Oct 2016 04:41:32 PM UTC, comment #8: 

Sebastian, can you comment on what Matlab really does now that 2016b has been released? From their documentation I don't see any reference about disabling automatic broadcasting or getting warnings about it.


From the documentation I found, they don't even make a big fuss about the implicit expansion, it's just part of their normal array operations.

Carnë Draug <carandraug>
Group Member
Fri 26 Aug 2016 05:34:51 PM UTC, comment #7: 


> warning ("error", "Octave:broadcast", "/my/favorite/path/");
>
> One would make broadcast warnings an error but only for functions in "/my/favorite/path/" (and possibly below, this needs to be discussed).


This would be quite a change for 4.2, probably not on time now.

I wonder how much of performance would it cause because it would no longer be just checking for an int. And such change would affect all warnings, and there's warnings for the use of endif, endfor, ! operator, double quotes, etc.

That proposal is quite intuitive but I wonder how to implement it. Anyway, it doesn't like it will go into 4.2 though.

Carnë Draug <carandraug>
Group Member
Mon 22 Aug 2016 04:30:30 PM UTC, comment #6: 


> How would you define user functions?


The user should know, e.g., this syntax would be quite intuitive:

warning ("error", "Octave:broadcast", "/my/favorite/path/");

One would make broadcast warnings an error but only for functions in "/my/favorite/path/" (and possibly below, this needs to be discussed).

Sebastian

Sebastian <sschoeps>
Mon 22 Aug 2016 04:22:05 PM UTC, comment #5: 


> I would also be very glad to make broadcasting raise an error (preferably only for user functions),


How would you define user functions?

I guess Octave functions and packages would not count. But what about m files in the path not written by the user himself but not in a package? Let's say that Agora would be working again, and someone downloads an m function from there. And what about oct files?

How do you think Octave should behave?

Carnë Draug <carandraug>
Group Member
Mon 22 Aug 2016 03:14:35 PM UTC, comment #4: 

I would also be very glad to make broadcasting raise an error (preferably only for user functions), see the discussion here:

http://octave.1599824.n4.nabble.com/Matlab-2016b-introduces-automatic-broadcasting-and-functions-in-scripts-td4679353.html

I am teaching Octave/Matlab courses and broadcasting is a real pain for students. I guess many Octave developers teach Octave and have similar experience.

Sebastian

Sebastian <sschoeps>
Sat 06 Aug 2016 02:39:07 PM UTC, comment #3: 

Lachlan:  I agree that we should probably reinstate the separate warning ID for broadcasting, at least for the 4.2 release.  Merging the warning with the general matlab-incompatible/language-extension warning seems to have been quite unpopular.

I've looked at your proposal for warnings, but that's fairly complex and I don't see any way of implementing that for 4.2.

John W. Eaton <jwe>
Group administrator
Sat 15 Aug 2015 12:32:11 AM UTC, comment #2: 

Admins, Please re-open this bug.  I was going to file a similar one.

Since 4.0.0, the "Octave:broadcast" warning has been merged into the "Octave:language-extension" warning.  It is impossible to issue warnings for broadcast without issuing them for legitimate language extensions (i.e., changes in the set of syntactically correct files).

Automatic broadcasting only provides syntactic sugar over using bsxfun, but makes debugging much harder.  For example, I frequently deal with lists of numbers.  I don't care if they are row vectors or column vectors.  Most matlab functions don't care, so I don't.  However, when I add a column to a row, I silently get a matrix, which causes an error to appear in an unrelated line of code, possibly very much later.

The patch to restore the warning is trivial, but I assume it was a policy decision.  How can I challenge that decision?

Lachlan Andrew <lachlan>
Fri 14 Aug 2015 02:53:15 PM UTC, comment #1: 

This is not an error, it is called broadcasting.
https://www.gnu.org/software/octave/doc/interpreter/Broadcasting.html

Have you disabled the respective warning?


@Admins: please close this bug.


Juan Pablo Carbajal <juanpi>
Group Member
Fri 14 Aug 2015 02:49:46 PM UTC, original submission:  

Addition of vectors with vectors and vectors with matrices with different dimensions should throw an error, but instead returns invalid results.  Example:

>> b=[1 2 3]; c=[1;2;3]; A=[1 2 3; 4 5 6];
>> b+c
ans =

   2   3   4
   3   4   5
   4   5   6

>> b+A
ans =

   2   4   6
   5   7   9
+verbatim+

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 rik5 (Posted a comment)
  • -email is unavailable- added by sschoeps (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by lachlan (Posted a comment)
  • -email is unavailable- added by juanpi (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 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-08-17 mtmiller Carbon-CopyRemoved 80942 -
    2018-08-17 mtmiller StatusNeed Info Wont Fix
        Open/ClosedOpen Closed
    2018-08-15 rik5 StatusNone Need Info
        Operating SystemMicrosoft Windows Any
    2016-08-06 jwe StatusInvalid / Not an Octave Bug None
        Open/ClosedClosed Open
    2015-08-14 mtmiller StatusNone Invalid / Not an Octave Bug
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code