unfold_split

Function unfold_split 

Source
pub fn unfold_split(
    t: &TensorDynLen,
    left_inds: &[DynIndex],
) -> Result<(Tensor, usize, usize, usize, Vec<DynIndex>, Vec<DynIndex>)>
Expand description

Unfold a tensor into a matrix by splitting indices into left and right groups.

This function validates the split, permutes the tensor so that left indices come first, and returns a rank-2 native tenferro tensor along with metadata.

§Arguments

  • t - Input tensor
  • left_inds - Indices to place on the left (row) side of the matrix

§Returns

A tuple (matrix_tensor, left_len, m, n, left_indices, right_indices) where:

  • matrix_tensor is a rank-2 tenferro::Tensor with shape [m, n]
  • left_len is the number of left indices
  • m is the product of left index dimensions
  • n is the product of right index dimensions
  • left_indices is the vector of left indices (cloned)
  • right_indices is the vector of right indices (cloned)

§Errors

Returns an error if:

  • The tensor rank is < 2
  • left_inds is empty or contains all indices
  • left_inds contains indices not in the tensor or duplicates
  • Native reshape fails