floating point or complex numbers type
list of dimension lengths. Each length must be greater then 1.
list of [start, end] pairs.
n-dimensional grid of evenly spaced numbers over specified intervals.
1D
auto s = linspace!double([5], [1.0, 2.0]); assert(s == [1.0, 1.25, 1.5, 1.75, 2.0]); // reverse order assert(linspace!double([5], [2.0, 1.0]) == s.retro); // remove endpoint s.popBack; assert(s == [1.0, 1.25, 1.5, 1.75]);
2D
import mir.functional: refTuple; auto s = linspace!double([5, 3], [1.0, 2.0], [0.0, 1.0]); assert(s == [ [refTuple(1.00, 0.00), refTuple(1.00, 0.5), refTuple(1.00, 1.0)], [refTuple(1.25, 0.00), refTuple(1.25, 0.5), refTuple(1.25, 1.0)], [refTuple(1.50, 0.00), refTuple(1.50, 0.5), refTuple(1.50, 1.0)], [refTuple(1.75, 0.00), refTuple(1.75, 0.5), refTuple(1.75, 1.0)], [refTuple(2.00, 0.00), refTuple(2.00, 0.5), refTuple(2.00, 1.0)], ]); assert(s.map!"a * b" == [ [0.0, 0.500, 1.00], [0.0, 0.625, 1.25], [0.0, 0.750, 1.50], [0.0, 0.875, 1.75], [0.0, 1.000, 2.00], ]);
Complex numbers
auto s = linspace!cdouble([3], [1.0 + 0i, 2.0 + 4i]); assert(s == [1.0 + 0i, 1.5 + 2i, 2.0 + 4i]);
Evenly spaced numbers over a specified interval.