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

 Submitted by: David Spies 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

You are not logged in

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>
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.

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:

Rik <rik5>
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:

Comment:

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?
This task has 0 encouragements so far.

Only project members can vote.