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

 Submitter: David Spies Submitted: 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
* Mandatory Fields

Post a Comment

Add a New Comment

Comment Type & Canned Response:

Discussion

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:

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

(1, 1) ->  1
j =  1

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>

Attached Files

(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)

Dependencies

Depends on the following items: None found

Items that depend on this one: None found

Mail Notification Carbon-Copy List

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)
•

Votes

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 project members can vote.

History

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

Powered by Savane 3.9