bugGNU Octave - Bugs: bug #59705, repelem error with sparse matrix...

 
 

bug #59705: repelem error with sparse matrix input

Submitter:  None
Submitted:  Thu 17 Dec 2020 03:38:29 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Fixed Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 6.1.0
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 20 Dec 2020 03:41:36 AM UTC, comment #3: 

I thought about that, but it didn't seem worth the effort.  Since sparse matrices are 2-D, >99% of all indexing is going to use one or two indices.  Rather than change all of the base code for that infrequent occurrence, it felt more sensible to just change this one instance in repelem.m.  It also had the advantage that this was an m-file so the change was quick and painless.

Rik <rik5>
Group administrator
Sat 19 Dec 2020 04:57:04 PM UTC, comment #2: 

Using more than 2 indices for sparse matrices also appears to fail in Matlab, but there's no reason for that if the additional indices are all either 1 or a colon.  So another way we could fix this is to allow x(i,j,:) to succeed for sparse.

John W. Eaton <jwe>
Group administrator
Fri 18 Dec 2020 01:59:52 AM UTC, comment #1: 

Good catch, and thanks for localizing the problem.  I checked in a fix on the stable branch of Octave here: http://hg.savannah.gnu.org/hgweb/octave/rev/900246a8bb37.  This will become part of the 6.1.1 bug fix release in a month or so.  If you need the fix sooner you can just download the m-file from the Octave mercurial repository.

Marking as fixed and closing report.

Rik <rik5>
Group administrator
Thu 17 Dec 2020 03:38:29 AM UTC, original submission:  

Problem description: repelem crashes with sparse input

q=rand(2);
repelem(q,1,2);%works without issue
repelem(sparse(q),1,2);
%error: sparse indexing needs 1 or 2 indices
%error: called from
%    repelem at line 246 column 12

To fix:
replace line 246

retval = x(idx1, idx2, :);

with

if issparse(x)
  retval = x(idx1, idx2);
else
  retval = x(idx1, idx2, :);
endif

Anonymous

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  •  

    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 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-12-18 rik5 StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code