This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen

Bug 224

Summary: Decide, implement and document what happens when LinSpaced is called with size = 1
Product: Eigen Reporter: Jitse Niesen <jitseniesen>
Component: Core - generalAssignee: Nobody <eigen.nobody>
Status: RESOLVED FIXED    
Severity: minor CC: chtz, gael.guennebaud, hauke.heibel, jacob.benoit.1
Priority: ---    
Version: 3.0   
Hardware: All   
OS: All   
Whiteboard:

Description Jitse Niesen 2011-03-18 11:27:58 UTC
I talked with Benoit about this yesterday over IRC but I had no time to finish so here are some notes so that we don't forget it.

The issue is what should LinSpaced(size, low, high) return when size = 1. It's not clear that this case is actually useful, but the nullary test fails currently if the randomly chosen size turns out to be 1 so something should be done about it.

I see three possibilities:

1. Return [high] (as a vector). This is what Matlab does.

2. Return [low] (as a vector). This is what NumPy does (though it's not documented).

3. Leave it undefined, i.e., require that size > 1. This is what Octave does. It's also basically what we are currently doing: at the moment we are returning a vector with a NaN in it. If we go for this option, we should probably add an assert(size>1).

Benoit initially thought that we should follow Matlab as that it as good a standard as there is. However, option 3 is easier to implement. 

In any case, we should document the decision and adapt the unit test.
Comment 1 Christoph Hertzberg 2013-11-06 11:14:57 UTC
This has been fixed long time ago:
https://bitbucket.org/eigen/eigen/commits/fff7d72dc748a9942a44f2717aebb5e4cdb0c599
For size==1 the high value is returned.
Comment 2 Nobody 2019-12-04 10:31:20 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/224.