New user self-registration is disabled due to spam. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.
Before reporting a bug, please make sure that your Eigen version is up-to-date!
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...
Status: RESOLVED FIXED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.0
Hardware: All All
: --- minor
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-18 11:27 UTC by Jitse Niesen
Modified: 2013-11-06 11:14 UTC (History)
4 users (show)



Attachments

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.

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