Skip to main content

repeat

Function repeat 

Source
pub fn repeat(a: &Array, repeats: usize, axis: Option<isize>) -> Result<Array>
Expand description

a with each element repeated repeats times along axis (of the flattened array without one), as MLX’s repeat.

use nuvec_core::{Array, Result, repeat};

let a = Array::from_slice(&[1i32, 2, 3, 4], &[2, 2])?;
assert_eq!(repeat(&a, 2, Some(1))?.to_vec::<i32>()?, [1, 1, 2, 2, 3, 3, 4, 4]);
assert_eq!(repeat(&a, 2, None)?.shape(), &[8]);