spyrit.core.meas.DynamicHadamSplit2d.reindex
- DynamicHadamSplit2d.reindex(x: tensor, axis: str = 'rows', inverse_permutation: bool = False) tensor[source]
Sorts a tensor along a specified axis using the indices tensor. The indices tensor is contained in the attribute
self.indices.The indices tensor contains the new indices of the elements in the values tensor. values[0] will be placed at the index indices[0], values[1] at indices[1], and so on.
Using the inverse permutation allows to revert the permutation: in this case, it is the element at index indices[0] that will be placed at the index 0, the element at index indices[1] that will be placed at the index 1, and so on.
Note
See
reindex()for more details.- Args:
values (
torch.tensor): The tensor to sort. Can be 1D, 2D, or any multi-dimensional batch of 2D tensors.axis (str, optional): The axis to sort along. Must be either ‘rows’ or ‘cols’. If values is 1D, axis is not used. Default is ‘rows’.
inverse_permutation (bool, optional): Whether to apply the permutation inverse. Default is False.
- Raises:
ValueError: If axis is not ‘rows’ or ‘cols’.
- Returns:
torch.tensor: The sorted tensor by the given indices along the specified axis.