This bugzilla service is closed. All entries have been migrated to
Bug 224 - Decide, implement and document what happens when LinSpaced is called with size = 1
Summary: Decide, implement and document what happens when LinSpaced is called with siz...
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.0
Hardware: All All
: --- minor
Assignee: Nobody
Depends on:
Reported: 2011-03-18 11:27 UTC by Jitse Niesen
Modified: 2019-12-04 10:31 UTC (History)
4 users (show)


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:
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'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:

Note You need to log in before you can comment on or make changes to this bug.