bugGNU Octave - Bugs: bug #41441, Broadcasting does not behave...

 
 

bug #41441: Broadcasting does not behave properly on sparse matrices

Submitted by:  David Spies <dspyz>
Submitted on:  Mon 03 Feb 2014 03:15:29 AM UTC  
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  None Assigned to:  None
Originator Name:  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.

 

Wed 31 Aug 2016 06:31:54 PM UTC, comment #5: 

Also a problem in SciPy apparently: https://github.com/scipy/scipy/issues/2128

Nir Krakauer <nir_krakauer>
Sat 03 Oct 2015 09:58:25 AM UTC, comment #4: 

Just added a related bug for the diagonal matrices:
https://savannah.gnu.org/bugs/index.php?46110

jan <pfa>
Sat 30 May 2015 07:24:20 PM UTC, comment #3: 

As I just discovered in my near-duplicate report #45219, one key factor is that combinations of one real and one complex sparse matrix fail.

t1 = randn(6,3)+1j*randn(6,3);
t2 = randn(6,1);
s1 = sparse(t1);
s2 = sparse(t2);

These work fine:

t1 + t2
bsxfun( @plus, t1, t2 )

These do not:

Michael C. Grant <mcgrant>
Sun 21 Sep 2014 10:36:40 AM UTC, comment #2: 

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

Sorry for the double post in ( https://savannah.gnu.org/bugs/?35787 ), feels free to removeone of them.

CH <atcl>
Fri 07 Feb 2014 10:01:02 PM UTC, comment #1: 

I have a sort of partial workaround.  Could someone look through it and see if they have any ideas to make it work completely? (It would already if not for bug #40341)

(file #30484)

David Spies <dspyz>
Mon 03 Feb 2014 03:15:29 AM UTC, original submission:  

Broadcasting doesn't work at all for sparse matrices.  There appears to be no good workaround

#Doesn't work automatically for sparse matrix with full vector
octave:1> a = sprand(100000,100000,0.00001);
octave:2> b = rand(100000,1);
octave:3> res = a == b;
error: mx_el_eq: nonconformant arguments (op1 is 100000x100000, op2 is 100000x1)

#Doesn't work explicitly for sparse matrix with full vector
octave:9> res = bsxfun(@eq,a,b);
error: out of memory or dimension too large for Octave's index type

#Doesn't work automatically for sparse matrix with sparse vector
octave:9> b = sparse(b);
octave:10> res = a == b;
error: mx_el_eq: nonconformant arguments (op1 is 100000x100000, op2 is 100000x1)

#Doesn't work explicitly for sparse matrix with sparse vector
octave:10> res = bsxfun(@eq,a,b);
error: out of memory or dimension too large for Octave's index type

#Often there's a special-case work-around, but it's generally unwieldy

octave:10> b_mat = diag(b) * spones(a);
octave:11> [i,j] = find(a);
octave:12> res = sparse(i,j,nonzeros(a) == nonzeros(b_mat));

David Spies <dspyz>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #30484:  spbsxfun.m added by dspyz (3KiB - text/x-objcsrc)

 

Depends on the following items: None found

Digest:
   bug dependencies.

 

Carbon-Copy List
  • -email is unavailable- added by nir_krakauer (Posted a comment)
  • -email is unavailable- added by pfa (Posted a comment)
  • -email is unavailable- added by mcgrant (Posted a comment)
  • -email is unavailable- added by atcl (Posted a comment)
  • -email is unavailable- added by dspyz (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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-12-01 rik5 Dependencies- => bugs #55141 is dependent
    2018-11-28 rik5 Dependencies- => bugs #55126 is dependent
    2014-02-07 dspyz Attached File- => Added spbsxfun.m, #30484

    Back to the top


    Powered by Savane 3.5