Decide, implement and document what happens when LinSpaced is called with size = 1
Submitted by Jitse Niesen
Assigned to Nobody
Link to original bugzilla bug (#224)
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:
Return [high] (as a vector). This is what Matlab does.
Return [low] (as a vector). This is what NumPy does (though it's not documented).
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.