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

 
 

bug #45589: sparse is fussy about dimension mismatching

Submitted by:  Ceral Paquet <octavebugs>
Submitted on:  Mon 20 Jul 2015 09:16:15 PM UTC  
 
Category: InterpreterSeverity: 2 - Minor
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: ConfirmedAssigned to: None
Originator Name: Open/Closed: Closed
Release: 4.0.0Operating System: GNU/Linux

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 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>
Project 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>
Project Member
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>
Project 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 File(s):
   
   
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
  • -unavailable- added by lachlan (Updated the item)
  • -unavailable- added by xyzdragon (Posted a comment)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by octavebugs (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):

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 02 Nov 2015 04:01:21 AM UTCrik5Item GroupNone=>Matlab Compatibility
      Open/ClosedOpen=>Closed
    Mon 14 Sep 2015 11:56:34 AM UTClachlanAttached File-=>Added sparse_xpose_assign.patch, #34875
    Thu 23 Jul 2015 04:05:56 AM UTCrik5CategoryNone=>Interpreter
      Severity3 - Normal=>2 - Minor
      StatusNone=>Confirmed

    Back to the top


    Powered by Savane 3.1-cleanup1