contract
full name: tenpy.algorithms.network_contractor.contract
parent module:
tenpy.algorithms.network_contractortype: function
- tenpy.algorithms.network_contractor.contract(tensor_list, tensor_names=None, leg_contractions=None, open_legs=None, sequence=None)[source]
Contract a network of tensors.
Based on the MatLab function
ncon.mas described in arXiv:1402.0939.- Parameters:
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], wheren1, n2are entries of tensor_names and each identify anArrayin tensor_list.l1, l2are leg labels of the correspondingArray. The instruction implies to contract legl1of tensorn1with legl2of tensorn2.open_legs (list of
[n1, l1, l]) – A list of instructions for “open” (uncontracted) legs.[n1, l1, l]implies that legl1of tensorn1is not contracted and is labelledlin 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.
- Returns:
result – The number or tensor resulting from the contraction.
- Return type:
Array| complex