bugGNU Octave - Bugs: bug #45589, sparse is fussy about dimension...

 
 

bug #45589: sparse is fussy about dimension mismatching

Submitter:  Ceral Paquet <octavebugs>
Submitted:  Mon 20 Jul 2015 09:16:15 PM UTC
   
 
Category:  Interpreter Severity:  2 - Minor
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 4.0.0 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 02 Nov 2015 04:01:21 AM UTC, comment #7: 

I checked this in under your name on the development branch (http://hg.savannah.gnu.org/hgweb/octave/rev/3d8aee0b7415).  Closing report.

Rik <rik5>
Group administrator
Mon 14 Sep 2015 11:56:34 AM UTC, comment #6: 

The attached patch implements the functionality requested.

Because of the constructor  sparse(a),  it can also assign, say, a 1x1x3 matrix to a 1x3 or 3x1 slice of a sparse matrix.

Please let me know if there are problems with this patch.


(file #34875)

Lachlan Andrew <lachlan>
Wed 29 Jul 2015 08:55:16 PM UTC, comment #5: 

I'm sorry, I don't know how this message ended up here, this was supposed to go to another bug.

ukuvbu oibws <xyzdragon>
Wed 29 Jul 2015 08:51:37 PM UTC, comment #4: 

Thanks to your suggestions I tested
dpkg -l '*blas*'
ii libblas-common     1.2.20110419-10 amd64
ii libblas-dev        1.2.20110419-10 amd64
ii libblas3           1.2.20110419-10 amd64
ii libopenblas-base   0.2.12-1        amd64
ii libopenblas-dev    0.2.12-1        amd64

After
  sudo apt-get purge libopenblas-base
it seems to work now.
The problem is, that purging openblas also purged Yade (because it is a dependency of libyade) which I need, but I guess this is a problem for the openblas or yade bug list :(

ukuvbu oibws <xyzdragon>
Thu 23 Jul 2015 06:39:21 PM UTC, comment #3: 

Just checked with A(:,1), A(1,:), 1:4 and (1:4)'. Matlab will accept any combination.

It won't accept this abuse for non-vectors tho (sparse or full): A(:,1:2) = randn(4,2) works but A(:,1:2) = randn(2,4) gives "Subscripted assignment dimension mismatch", as you'd hope it would.

Ceral Paquet <octavebugs>
Thu 23 Jul 2015 06:31:26 PM UTC, comment #2: 

Matlab tolerates it, I just checked.

% below is from Matlab 2013a

>> A=zeros(4,4);
>> A(:,1)=1:4


A =

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

>> A(1,:)=1:4


A =

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

>> A=sparse(4,4);
>> A(:,1)=1:4


A =

   (1,1)        1
   (2,1)        2
   (3,1)        3
   (4,1)        4

>> A(1,:)=1:4


A =

   (1,1)        1
   (2,1)        2
   (3,1)        3
   (4,1)        4
   (1,2)        2
   (1,3)        3
   (1,4)        4

Ceral Paquet <octavebugs>
Thu 23 Jul 2015 04:05:56 AM UTC, comment #1: 

Confirmed.

Do you have access to Matlab?  It would be nice to see how they handle it.

But I agree it would be nice to make this compatible with the case of full matrices.

Rik <rik5>
Group administrator
Mon 20 Jul 2015 09:16:15 PM UTC, original submission:  

It's not really a bug, just a difference between sparse and full matrices. I guess sparse should be tolerant of this kind of abuse, just like it's full sibling :)


>> A=zeros(4,4);
>> A(:,1) = 1:4

A =

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

>> A=sparse(4,4);
>> A(:,1) = 1:4

error: A(I,J,...) = X: dimensions mismatch

>> A(:,1) = (1:4)'

A =

Compressed Column Sparse (rows = 4, cols = 4, nnz = 4 [25%])

  (1, 1) ->  1
  (2, 1) ->  2
  (3, 1) ->  3
  (4, 1) ->  4

>> full(A)

ans =

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

Ceral Paquet <octavebugs>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #34875:  sparse_xpose_assign.patch added by lachlan (809B - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by lachlan (Updated the item)
  • -email is unavailable- added by xyzdragon (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by octavebugs (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-11-02 rik5 Item GroupNone Matlab Compatibility
        Open/ClosedOpen Closed
    2015-09-14 lachlan Attached File- Added sparse_xpose_assign.patch, #34875
    2015-07-23 rik5 CategoryNone Interpreter
        Severity3 - Normal 2 - Minor
        StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code