bsc-quantic / Tensors.jl

Tensors and Einstein Summation in Julia
https://bsc-quantic.github.io/Tensors.jl/
Apache License 2.0
0 stars 1 forks source link

Add `truncatedims!` function #19

Closed jofrevalles closed 1 year ago

jofrevalles commented 1 year ago

Description

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)