bugGNU Octave - Bugs: bug #38151, Empty length in a linspace

 
 

bug #38151: Empty length in a linspace

Submitter:  Marco Caliari <caliari>
Submitted:  Wed 23 Jan 2013 02:04:47 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 3.6.2 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 21 Feb 2013 12:31:43 AM UTC, comment #2: 

It's not documented, but apparently Matlab produces B for linspace (A, B, []).  It would not be hard to fix this, so I say why not?  I checked in the following change:

http://hg.savannah.gnu.org/hgweb/octave/rev/39129305b914

John W. Eaton <jwe>
Group administrator
Wed 20 Feb 2013 11:48:18 PM UTC, comment #1: 

I think that Octave probably has the correct behavior.

According to the linspace documentation it wants a scalar number N for the number of points.  The empty matrix is not zero (a scalar number), but an entirely different data type (matrix).  It seems fine to flag the user that linspace has been called incorrectly.  The error message also points out

error: linspace: N must be an integer

which gives a good clue about what a user would need to do to make it work.

Rik <rik5>
Group administrator
Wed 23 Jan 2013 02:04:47 PM UTC, original submission:  

Dear maintainers,

what should be the result of


linspace(0,1,[])


Actually (3.6.2), it is an error. If I consider the following case


v = 1:4;
idx = find (v > 2);
linspace (min (idx), max (idx), length (idx))
linspace (min (idx), max (idx), max (idx) - min (idx) + 1);


the last two lines give the same result [3,4]. But if I consider
the same example with


idx = find (v > 4); % idx = [](1x0)


the second last line works (although giving the transposed result [](0x1)) and the last line does not work.
If I do the same in Matlab, I get [](1x0) and error, respectively.
I do not know what "should" be the result and, of course, it is a corner case.

Marco

Marco Caliari <caliari>
Group Member

 

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

    Date Changed by Updated Field Previous Value => Replaced by
    2013-02-21 jwe Item GroupFeature Request Matlab Compatibility
        StatusWont Fix Fixed
    2013-02-20 rik5 StatusNone Wont Fix
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code