Skip to content

Function similar to Matlab's/Octave's colon operator

Submitted by Christoph Hertzberg @chhtz

Assigned to Nobody

Link to original bugzilla bug (#699)
Version: 3.3 (current stable)

Description

Sometimes, instead of using LinSpaced it would be more convenient to have an expression similar to Matlab's colon operator. E.g.
0:5:15 = {0, 5, 10, 15} (instead of LinSpaced(4,0,15))

Suggestion: DenseBase::Range(size, low, stepsize) and for fixed size types: Range(low, stepsize). However, if we default stepsize to 1, there would be an ambiguity between Range(size, low) and Range(low, stepsize).
The return type could actually be shared with the current LinSpaced return type (at least for floating point types (cf. Bug #698 (closed)).

For dynamic sized ranges, instead of specifying the size an alternative syntax which requires an upper bound might also be possible.
I'm also not sure, if Range is the best name for it.

Depends on

#329 (closed)

Blocking

#814 (closed)

Edited by Eigen Bugzilla