In order to make it more convenient to truncate dimensions for our Tensor struct, we would like to add a new function truncatedims! that takes a Tensor, the dimension to truncate (either by index or label), and the last index to keep. The function should modify the input Tensor in-place by updating its data and labels fields.
Example usage
using Tensors
U = Tensor(rand(4, 4), (:i, :j))
truncatedims!(U, :j, 2)
Description
In order to make it more convenient to truncate dimensions for our
Tensor
struct, we would like to add a new functiontruncatedims!
that takes aTensor
, the dimension to truncate (either by index or label), and the last index to keep. The function should modify the inputTensor
in-place by updating itsdata
andlabels
fields.Example usage