full name: tenpy.algorithms.network_contractor.contract
- tenpy.algorithms.network_contractor.contract(tensor_list, tensor_names=None, leg_contractions=None, open_legs=None, sequence=None)¶
Contract a network of tensors.
Based on the MatLab function
ncon.mas described in arXiv:1402.0939.
tensor_list (list of
Array) – The tensors to be contracted.
leg_contractions (list of
[n1, l1, n2, l2]) – A list of contraction instructions. An entry of leg_contractions has the form
[n1, l1, n2, l2], where
n1, n2are entries of tensor_names and each identify an
l1, l2are leg labels of the corresponding
Array. The instruction implies to contract leg
open_legs (list of
[n1, l1, l]) – A list of instructions for “open” (uncontracted) legs.
[n1, l1, l]implies that leg
n1is not contracted and is labelled
lin the result.
tensor_names (list of str) – A list of names for each tensor, to be used in leg_contractions and open_legs. The default value is list(range(len(tensor_list))), so that the tensor “names” are
0, 1, 2, ....
sequence (list of int) – The order in which the leg_contractions are to be performed. An entry of network_contractor.outer_product indicates performing an outer product. This corresponds to the zero-in-sequence convention of arXiv:1304.6112
result – The number or tensor resulting from the contraction.
- Return type