pub fn linspace<U, T>(
start: U,
stop: U,
options: LinspaceOptions,
) -> Result<Array>where
U: NumCast,
T: ArrayElement,Expand description
Generate evenly spaced values between start and stop.
A negative count errors, zero returns an empty array, and one returns start. When endpoint
is false, the interval is divided by count and stop is excluded. Endpoints are converted
directly to the C ABI’s double representation.
use mlx_rs::{ops::{linspace, LinspaceOptions}, with_stream, Stream};
// float64 runs on the CPU only.
let output = with_stream(&Stream::cpu(), || {
linspace::<_, f64>(
16_777_217.0_f64,
16_777_219.0_f64,
LinspaceOptions {
count: 3,
endpoint: true,
},
)
})
.unwrap();
assert_eq!(output.shape(), &[3]);