macro_rules! srange {
($size: expr, $shape: expr) => { ... };
($start: expr, $end: expr, $shape: expr) => { ... };
($start: expr, $end: expr, $step: expr, $shape: expr) => { ... };
}Expand description
Build a tensor of evenly spaced values and reshape it in one step.
Like arange!, but takes a target shape as the final argument and lays
the values out row-major into it. Panics if the number of values doesn’t
equal the product of shape.
srange!(size, shape)- values0..size, reshaped toshape.srange!(start, end, shape)- valuesstart..end, reshaped toshape.srange!(start, end, step, shape)- valuesstart..endbystep, reshaped toshape.
§Examples
use candela::{srange, Dimension, Tensor};
let t: Tensor<f64> = srange![6, &[2, 3]];
assert_eq!(t.shape(), &[2, 3]);
assert_eq!(t.data(), &[0.0, 1.0, 2.0, 3.0, 4.0, 5.0]);