bugGNU Octave - Bugs: bug #35787, Diagonal matrices don't broadcast

 
 

bug #35787: Diagonal matrices don't broadcast

Submitted by:  None
Submitted on:  Sun 11 Mar 2012 06:39:16 AM UTC  
 
Category:  Libraries Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Confirmed Assigned to:  Jordi GutiĆ©rrez Hermoso <jordigh>
Originator Name:  forkandwait Originator Email:  -email is unavailable-
Open/Closed:  Open Release:  dev
Operating System:  Any

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

( Jump to the original submission)

Mon 23 Dec 2019 05:37:26 PM UTC, comment #7: 

Found this bug after seeing (and answering) this question on StackOverflow: https://stackoverflow.com/q/59452260/4183191

I'm surprised this is a 2012 bug. I thought I'd comment here to point out occurrences of the bug do exist in the wild still.

Looking forward to octave v6 :)

Tasos Papastylianou <tpapastylianou>
Thu 15 Dec 2016 11:18:05 AM UTC, comment #6: 

see also bug #41441 .

Hartmut <hardy>
Sat 19 Nov 2016 08:24:38 PM UTC, comment #5: 

These issues are still all present in Octave 4.2.0.

Hartmut <hardy>
Sat 11 Jul 2015 03:50:15 AM UTC, comment #4: 

This is still an issue in version 4.0.0.

It is easy to work around by placing the diagonal matrix in [...]:

> [eye(2)] + [1 0]

ans =

   2   0
   1   1

However, that is not done in some library routines (I was bitten by mvnrnd.m) and so Matlab-compliant user code that does not rely on automatic broadcasting can be affected.  The bug has been open for three years; is it time to rewrite all library routines to work around it?

Another surprising twist is that a slice of a diagonal matrix is still considered "diagonal".

> a = eye(2);
> b = a(1,:)

b =

Diagonal Matrix

   1   0

> b + [1; 0]

error: operator +: nonconformant arguments (op1 is 1x2, op2 is 2x1)

Lachlan Andrew <lachlan>
Sun 21 Sep 2014 10:32:30 AM UTC, comment #3: 

I encountered something similar with automatic broadcasting and sparse vectors:

ones(3,10).*[0;2;0] # works as expected

ones(3,10).*sparse(2,1,2,3,1) # does not work

and yields the following error message:
error: product: nonconformant arguments (op1 is 3x10, op2 is 3x1)

I am on version 3.8.1

CH <atcl>
Sun 19 Jan 2014 10:35:43 PM UTC, comment #2: 

Still present on the current development version of Octave (hg rev c1baf94184af):

octave-cli:1> eye (4) .- (1:4)'
error: operator -: nonconformant arguments (op1 is 4x4, op2 is 4x1)
octave-cli:2> full (eye (4)) .- (1:4)'
warning: operator -: automatic broadcasting operation applied
ans =

   0  -1  -1  -1
  -2  -1  -2  -2
  -3  -3  -2  -3
  -4  -4  -4  -3

Mike Miller <mtmiller>
Project Administrator
Sun 11 Mar 2012 07:25:38 AM UTC, comment #1: 

Hm, I guess I missed a few cases with the diagonal matrices. I'll look into it.

Jordi GutiƩrrez Hermoso <jordigh>
Project AdministratorIn charge of this item.
Sun 11 Mar 2012 06:39:16 AM UTC, original submission:  

I think broadcasting should work like #12, but #10 gives error.

10>  eye(4) .- (1:4)'
error: operator -: nonconformant arguments (op1 is 4x4, op2 is 4x1)
11>  eye(4) .* (1:4)'
warning: product: automatic broadcasting operation applied
ans =

   1   0   0   0
   0   2   0   0
   0   0   3   0
   0   0   0   4

12>  eye(4) .- repmat((1:4)',1,4)
ans =

   0  -1  -1  -1
  -2  -1  -2  -2
  -3  -3  -2  -3
  -4  -4  -4  -3

13> version
ans = 3.6.1-rc0

Anonymous

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Carbon-Copy List
  • -email is unavailable- added by tpapastylianou (Posted a comment)
  • -email is unavailable- added by hardy (Posted a comment)
  • -email is unavailable- added by lachlan (Posted a comment)
  • -email is unavailable- added by atcl (Posted a comment)
  • -email is unavailable- added by jordigh (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-12-23 mtmiller Carbon-CopyRemoved 80942 => -
    2016-11-20 rik5 Dependencies- => bugs #37538 is dependent
    2015-10-03 mtmiller Dependencies- => bugs #46110 is dependent
    2014-01-19 mtmiller CategoryNone => Libraries
        Release3.6.1 => dev
        Operating SystemBSD => Any
    2013-07-11 jordigh Dependencies- => bugs #39462 is dependent
    2013-07-11 jordigh SummaryBroadcasting inconsistency => Diagonal matrices don't broadcast
    2012-03-11 jordigh StatusNone => Confirmed
        Assigned toNone => jordigh

    Back to the top


    Powered by Savane 3.5