bugGNU Octave - Bugs: bug #54143, Why can't issorted() work on...

 
 

bug #54143: Why can't issorted() work on matrices?

Submitter:  Dan Sebald <sebald>
Submitted:  Mon 18 Jun 2018 07:44:17 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 19 Jun 2018 05:14:48 AM UTC, comment #3: 

Just to test, I commented out the test for vectors in issorted in data.cc.  Octave compiles and runs fine, but issorted seems to always return 0 then for matrices.  Internally, it seems that


issorted (matrix)
=>
issorted (matrix(:))


so the whole thing looks like a vector to issorted.

Rik <rik5>
Group administrator
Tue 19 Jun 2018 01:30:51 AM UTC, comment #2: 

Also, liboctave/array/Array.h which is the basis for all of the ND-Array and Matrix classes has an issorted member function.

Rik <rik5>
Group administrator
Mon 18 Jun 2018 10:23:47 PM UTC, comment #1: 

Yeah, this doesn't really make sense.  Consider Matlab's description of the issorted function (http://www.mathworks.com/help/matlab/ref/issorted.html).


If A is a vector, then issorted returns 1 when the vector elements are in ascending order.

If A is a matrix, then issorted returns 1 when each column of A is in ascending order.

If A is a multidimensional array, then issorted returns 1 when A is in ascending order along the first dimension whose size does not equal 1.


They seem to be able to do it, we should too.

Rik <rik5>
Group administrator
Mon 18 Jun 2018 07:44:17 PM UTC, original submission:  

The sort() function works on matrices, yet the issorted() function doesn't, e.g.,


octave:7> X = magic(5);
octave:8> sort(X)
ans =

    4    5    1    2    3
   10    6    7    8    9
   11   12   13   14   15
   17   18   19   20   16
   23   24   25   21   22

octave:9> issorted(sort(X))
error: issorted: needs a vector


One would think that issorted() is a counterpart to sort(), so it should work on whatever the sorted routine creates.

Dan Sebald <sebald>

 

(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 rik5 (Posted a comment)
  • -email is unavailable- added by sebald (Submitted the item)
  •  

    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
    2018-06-18 rik5 Item GroupNone Matlab Compatibility
        StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code