Closed jofrevalles closed 1 month ago
Marked with the "on hold" label, since we are waiting for the new refactor to be merged
replace!
method that can replace a Tensor
with a TensorNetwork
as long as the open indices of the TensorNetwork
match the labels of the Tensor
.We could now enhance the replace!
function so it enables the replacement of tensors that have different labels. However, we should discuss how we want that and what happens to the other tensors connected to the replaced tensor.
Update: this can be already implemented
Update: this can be already implemented
But we haven't discussed the semantics yet... I have concerns on adding new labels not in the Tensor Network (or renaming) or resizing an index from a Tensor
.
If you suggest some coherent semantics, I will consider them.
@jofrevalles I think we can close this since we now have @unsafe_region
right?
Yes!
Summary
Currently, the
replace!
function can replace aTensor
within aTensorNetwork
but only under the condition that the newTensor
has the samelabels
as the original one. This restriction imposes a considerable limitation on our usage of this function, especially in scenarios where we might want to replace a tensor with another one that differs in size and consequently, in labels.At the moment, this implementation could potentially introduce problems. Specifically, the
TensorNetwork
has aninds
field that links indexes with tensors. In its current form, we cannot add a new index to aTensorNetwork
because of the immutable nature of this struct.The recent refactor presented in PR #55 removes the
inds
field, allowing a more generalized replacement of tensors like the one just explained.