remap

remap#

Remaps an input operator by selecting items from an input index operator

template<int DIM, typename Op, typename Ind>
auto __MATX_INLINE__ matx::remap(const Op &t, Ind idx)#

Operator to logically remap elements of an operator based on an index array/operator.

The rank of the output tensor is equal to the rank of the input tensor. The rank of the index tensor must be 0 or 1.

The size of the output tensor is the same as the input tensor except in the applied dimenions. In the applied dimension the size of the output tensor is equal to the size of the index tensor. In the case of a 0-rank index tensor, the size of the output tensor in the corresponding dimension is always 1.

This operator can appear as an rvalue or lvalue.

Template Parameters:
  • DIM – Dimension to apply the remap

  • T – Input operator/tensor type

  • Ind – Input index Operator type

Parameters:
  • t – Input operator

  • idx – Index operator/tensor

Returns:

Value in t from each location in idx

template<int DIM, int... DIMS, typename Op, typename Ind, typename ...Inds>
auto __MATX_INLINE__ matx::remap(const Op &t, Ind idx, Inds... inds)#

Operator to logically remap elements of an operator based on an index array/operator.

The rank of the output tensor is equal to the rank of the input tensor. The rank of the index tensor must be 0 or 1. The number of DIMS and the number of Inds provided must be the same.

The size of the output tensor is the same as the input tensor except in the applied dimenions. In the applied dimension the size of the output tensor is equal to the size of the index tensor. In the case of a 0-rank index tensor, the size of the output tensor in the corresponding dimension is always 1.

This operator can appear as an rvalue or lvalue.

Template Parameters:
  • DIM – Dimension to apply the remap

  • DIMS... – list of multiple dimensions to remap along

  • T – Input operator/tensor type

  • Ind – Input index Operator type

  • Inds... – list of multiple index operators to remap along

Parameters:
  • t – Input operator

  • idx – Index operator/tensor

  • inds – list of multiple index operators to remap along

Returns:

Value in t from each location in idx

Examples#

auto tov = make_tensor<TestType>({N, N});
auto idx = make_tensor<int>({N});

for(int i = 0; i < N; i++) {
  idx(i) = i;
}

// Remap 2D operator "tiv" by selecting elements from dimension 0 stored in "idx"
(tov = remap<0>(tiv, idx)).run(exec);
// Remap 2D operator "tiv" by selecting elements from dimensions 0 and 1 stored in "idx"
(tov = remap<0,1>(tiv, idx, idx)).run(exec);