bugGNU Octave - Bugs: bug #41512, max() of sparse logical matrix...


bug #41512: max() of sparse logical matrix fails

Submitted by:  David Spies <dspyz>
Submitted on:  Sat 08 Feb 2014 06:34:56 PM UTC  
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  Closed
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.


Tue 16 Feb 2016 12:48:52 AM UTC, comment #4: 

I committed the patch here (http://hg.savannah.gnu.org/hgweb/octave/rev/f780d057a3ec).  Marked as fixed and closing report.

Rik <rik5>
Project Administrator
Thu 14 Jan 2016 09:01:20 AM UTC, comment #3: 

The attached changeset fixes this bug.

Rik, are you sure that the returned index value should be sparse too?  I know that the policy is to return the same type as the argument, but it isn't returned as a logical, so we're not returning it as the same type anyway.  I decided to leave it as a regular array.

(file #36025)

Lachlan Andrew <lachlan>
Sat 08 Feb 2014 10:38:32 PM UTC, comment #2: 

Confirmed.  This is actually a regression that happened sometime between 3.2.4 and 3.4.3.  Even in 3.2.4 the behavior isn't totally perfect because the return value j should be a sparse matrix.

3.2.4 example code:

i = Compressed Column Sparse (rows = 1, cols = 1, nnz = 1 [1e+02%])

  (1, 1) ->  1
j =  1

Rik <rik5>
Project Administrator
Sat 08 Feb 2014 08:18:08 PM UTC, comment #1: 

a simpler offending case: [i,j]=max(sparse(true))
(although i=max(sparse(true)) works fine)

Felipe G. Nievinski <fgnievinski>
Sat 08 Feb 2014 06:34:56 PM UTC, original submission:  

Looking at the second return value of max(a,[],2) is a way to find the index of the first true element in each row of a.

matlab supports this when a is sparse logical, but octave gives an error:

octave:7> [i,j] = max(logical(speye(3)),[],2);
error: octave_base_value::int8_array_value(): wrong type argument 'sparse bool matrix'

Of course you can always just convert the argument to double

David Spies <dspyz>


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

Attach Files:

Attached Files
file #36025:  bug_41512.cset added by lachlan (2KiB - application/octet-stream)


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 rik5 (Posted a comment)
  • -email is unavailable- added by fgnievinski (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-02-16 rik5 StatusConfirmed => Fixed
        Open/ClosedOpen => Closed
    2016-01-14 lachlan Attached File- => Added bug_41512.cset, #36025
    2014-02-08 rik5 Item GroupMatlab Compatibility => Regression
        StatusNone => Confirmed
        SummaryTake max of sparse logical matrix => max() of sparse logical matrix fails

    Back to the top

    Powered by Savane 3.7