Add a replace! function that allows users to replace a specific Tensor within a TensorNetwork. The function should ensure that the new Tensor maintains the same connections with respect to the labels as the original Tensor.
The replace! function should have the following input parameters and expected behavior:
Input: TensorNetwork, index of the Tensor to be replaced, new Tensor
Output: Updated TensorNetwork with the specified Tensor replaced
Checks: Verify that the new Tensor is compatible with the existing TensorNetwork, maintaining the same label connections
Example
function replace!(state::TensorNetwork, index::Int, new_tensor::Tensor)
# Perform checks and update the state
...
end
Summary
Add a
replace!
function that allows users to replace a specificTensor
within aTensorNetwork
. The function should ensure that the newTensor
maintains the same connections with respect to thelabels
as the originalTensor
.The
replace!
function should have the following input parameters and expected behavior:TensorNetwork
, index of theTensor
to be replaced, newTensor
TensorNetwork
with the specifiedTensor
replacedTensor
is compatible with the existingTensorNetwork
, maintaining the same label connectionsExample