20 #ifndef TENSOR_LINSPACE_HPP
21 #define TENSOR_LINSPACE_HPP
23 #include <tensor/gen.h>
27 template<
typename elt_t>
28 static inline const Tensor<elt_t>
29 do_linspace(
const Tensor<elt_t> &min,
const Tensor<elt_t> &max, index n = 100)
32 Tensor<elt_t> output(d, n);
36 const Tensor<elt_t> base =
reshape(max, d);
37 const Tensor<elt_t> delta =
reshape((max - min) / (n - 1.0), d);
38 for (index i = 0; i < n; i++) {
39 output.at(range(), range(i)) = delta * (double)i + min;
45 return reshape(output, min.dimensions() << (igen << n));
51 #endif // TENSOR_LINSPACE_HPP
const RTensor reshape(const RTensor &t, const Indices &new_dims)
Return a RTensor with same data and given dimensions.