[ITensors] [ENHANCEMENT] In-place operations with unequal dimensions of indices. #1160
Labels
enhancement
New feature or request
ITensors
Issues or pull requests related to the `ITensors` package.
Is your feature request related to a problem? Please describe.
Allocations reduction is a key to writing performant code. While, e.g., an operation like
A .= B .* C
is available, it assumes thatA
andB*C
have the same indices, which, among other things, means that dimensions of indices must be the same. To write optimal code, sometimes it would be useful to lift this requirement.For example, suppose we do a 2-site DMRG update. This requires merging
m_combined = m_{i} * m_{i+1}
, updating itm_combined -> m_combined^*
, splitting itm_combined^* = U * S * V
, cuttingS
and then updatingm_{i} -> U
andm_{i+1} = S * V
, i.e. creating newm_{i}
andm_{i+1}
tensors. For some applications, to reduce allocations, it would be useful to be able to pre-allocate large enoughm_i
and update them in-place. While it is simple in pure Julia, I wonder how hard it would be to have it in ITensors.Describe the solution you'd like
It would be useful to have some helper functions allowing for in-place operations with tensors with indices of unequal dimensions.
Describe alternatives you've considered
So far, alternatives have been writing code in pure Julia and miss rich ITensors functionality or to enjoy simplicity and power of ITensors at a cost of extra allocations.
The text was updated successfully, but these errors were encountered: