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 FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: NoneAssigned to: None
Originator Name: Open/Closed: Open
Release: devOperating 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.

These work fine:

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 File(s):
   
   
Comment:
   

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

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by nir_krakauer (Posted a comment)
  • -unavailable- added by pfa (Posted a comment)
  • -unavailable- added by mcgrant (Posted a comment)
  • -unavailable- added by atcl (Posted a comment)
  • -unavailable- added by dspyz (Submitted the item)
  •  

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

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 07 Feb 2014 10:01:02 PM UTCdspyzAttached File-=>Added spbsxfun.m, #30484

    Back to the top


    Powered by Savane 3.1-cleanup1