tile_2d

Function tile_2d 

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

Repeat an array by tiling it in multiple dimensions

§Arguments

  • array - The input 2D array
  • reps_axis_0 - Number of times to repeat the array along axis 0
  • reps_axis_1 - Number of times to repeat the array along axis 1

§Returns

A new array formed by repeating the input array

§Examples

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

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

// Tile array to repeat it 2 times along axis 0 and 3 times along axis 1
let tiled = tile_2d(a.view(), 2, 3);
assert_eq!(tiled.shape(), &[4, 6]);
assert_eq!(tiled,
    array![
        [1, 2, 1, 2, 1, 2],
        [3, 4, 3, 4, 3, 4],
        [1, 2, 1, 2, 1, 2],
        [3, 4, 3, 4, 3, 4]
    ]
);