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 FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Regression
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: devOperating System: Any

Add a New Comment (Rich MarkupRich 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>
Project Member
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:

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

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


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 rik5 (Posted a comment)
  • -unavailable- added by fgnievinski (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):



    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 16 Feb 2016 12:48:52 AM UTCrik5StatusConfirmed=>Fixed
    Thu 14 Jan 2016 09:01:20 AM UTClachlanAttached File-=>Added bug_41512.cset, #36025
    Sat 08 Feb 2014 10:38:32 PM UTCrik5Item GroupMatlab Compatibility=>Regression
      SummaryTake max of sparse logical matrix=>max() of sparse logical matrix fails

    Back to the top

    Powered by Savane 3.1-cleanup