Skip to main content

movedim

Function movedim 

Source
pub fn movedim<T: Clone>(
    arr: &Slice<T, DynRank>,
    src: usize,
    dst: usize,
) -> Tensor<T, DynRank>
Expand description

Move axis from position src to position dst

This is equivalent to numpy.moveaxis or libsparseir’s movedim. It creates a permutation array that moves the specified axis.

§Arguments

  • arr - Input array slice (Tensor or View)
  • src - Source axis position
  • dst - Destination axis position

§Returns

Tensor with axes permuted

§Example

// For a 4D tensor with shape (2, 3, 4, 5)
// movedim(arr, 0, 2) moves axis 0 to position 2
// Result shape: (3, 4, 2, 5) with axes permuted as [1, 2, 0, 3]