jet.bindings.slice_index

slice_index(*args, **kwargs)

Overloaded function.

  1. slice_index(tensor: jet.bindings.TensorC64, index: str, value: int) -> jet.bindings.TensorC64

Slices a tensor object index. The result is a tensor object whose indices and data are a subset of the provided tensor object, sliced along the given index argument.

Parameters
  • tensor (Tensor) – Reference tensor object.

  • index (str) – Index label on which to slice.

  • value (int) – Value to slice the index on.

Returns

Slice of the tensor object.

Return type

Tensor

Example

Suppose that \(A(i,j)\) is a 2x3 tensor. Then,

import jet

A = jet.Tensor({"i", "j"}, {2, 3})
A.fill_random()

jet.slice_index(A, "i", 0) # Result is a 1x3 tensor
jet.slice_index(A, "i", 1) # Result is a 1x3 tensor

jet.slice_index(A, "j", 0) # Result is a 2x1 tensor
jet.slice_index(A, "j", 1) # Result is a 2x1 tensor
jet.slice_index(A, "j", 2) # Result is a 2x1 tensor
  1. slice_index(tensor: jet.bindings.TensorC128, index: str, value: int) -> jet.bindings.TensorC128

Slices a tensor object index. The result is a tensor object whose indices and data are a subset of the provided tensor object, sliced along the given index argument.

Parameters
  • tensor (Tensor) – Reference tensor object.

  • index (str) – Index label on which to slice.

  • value (int) – Value to slice the index on.

Returns

Slice of the tensor object.

Return type

Tensor

Example

Suppose that \(A(i,j)\) is a 2x3 tensor. Then,

import jet

A = jet.Tensor({"i", "j"}, {2, 3})
A.fill_random()

jet.slice_index(A, "i", 0) # Result is a 1x3 tensor
jet.slice_index(A, "i", 1) # Result is a 1x3 tensor

jet.slice_index(A, "j", 0) # Result is a 2x1 tensor
jet.slice_index(A, "j", 1) # Result is a 2x1 tensor
jet.slice_index(A, "j", 2) # Result is a 2x1 tensor