quimb
quimb copied to clipboard
TN: index mangling doesn't trigger when inner index matches *outer* index
In the following, the 'b' index should be mangled on the first TN upon combination:
>>> import quimb.tensor as qtn
>>> qtn.rand_tensor([2, 2], ['a', 'b']) & qtn.rand_tensor([2, 2], ['b', 'c'])
>>> print(tn1 & qtn.rand_tensor([2, 2], ['b', 'c']))
TensorNetwork([
Tensor(shape=(2, 2), inds=('a', 'b'), tags=set()),
Tensor(shape=(2, 2), inds=('b', 'c'), tags=set()),
Tensor(shape=(2, 2), inds=('b', 'c'), tags=set()),
])
This is because it is an inner index and therefore shouldn't be automatically matched up, whereas on the second tensor the 'b' is an outer index so should be preserved.
Possibly mangle all indices apart from when 'virtually' combining?