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: tuple; auto s = linspace!double([5, 3], [1.0, 2.0], [0.0, 1.0]); assert(s == [ [tuple(1.00, 0.00), tuple(1.00, 0.5), tuple(1.00, 1.0)], [tuple(1.25, 0.00), tuple(1.25, 0.5), tuple(1.25, 1.0)], [tuple(1.50, 0.00), tuple(1.50, 0.5), tuple(1.50, 1.0)], [tuple(1.75, 0.00), tuple(1.75, 0.5), tuple(1.75, 1.0)], [tuple(2.00, 0.00), tuple(2.00, 0.5), tuple(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
import mir.complex; alias C = Complex!double; auto s = linspace!C([3], [C(1.0, 0), C(2.0, 4)]); assert(s == [C(1.0, 0), C(1.5, 2), C(2.0, 4)]);
Evenly spaced numbers over a specified interval.