38 using Vec = std::valarray<double>;
41 using Strings = std::vector<std::string>;
44 template <
typename T0,
typename T1,
typename U =
double>
45 auto linspace(T0 x0, T1 x1, std::size_t numintervals) -> std::valarray<U>
47 std::valarray<U> result(numintervals + 1);
48 for(std::size_t i = 0; i <= numintervals; ++i)
49 result[i] = x0 + i * (x1 - x0) /
static_cast<U
>(numintervals);
54 template <
typename U =
double>
55 auto range(
int x0,
int x1) -> Vec
57 const auto incr = (x1 > x0) ? +1 : -1;
58 std::valarray<U> result(x1 - x0 + 1);
59 for(std::size_t i = 0; i < result.size(); ++i)
60 result[i] = x0 + i * incr;