repeat_2d

Function repeat_2d 

Source
pub fn repeat_2d<T>(
    array: ArrayView<'_, T, Ix2>,
    repeats_axis_0: usize,
    repeats_axis_1: usize,
) -> Array<T, Ix2>
where T: Clone + Default + Zero,
Expand description

Repeat array elements by duplicating values

§Arguments

  • array - The input 2D array
  • repeats_axis_0 - Number of times to repeat each element along axis 0
  • repeats_axis_1 - Number of times to repeat each element along axis 1

§Returns

A new array with elements repeated as specified

§Examples

use ndarray::array;
use scirs2_core::ndarray_ext::manipulation::repeat_2d;

let a = array![[1, 2], [3, 4]];

// Repeat array elements 2 times along axis 0 and 3 times along axis 1
let repeated = repeat_2d(a.view(), 2, 3);
assert_eq!(repeated.shape(), &[4, 6]);
assert_eq!(repeated,
    array![
        [1, 1, 1, 2, 2, 2],
        [1, 1, 1, 2, 2, 2],
        [3, 3, 3, 4, 4, 4],
        [3, 3, 3, 4, 4, 4]
    ]
);