contract¶
full name: tenpy.algorithms.network_contractor.contract
parent module:
tenpy.algorithms.network_contractor
type: 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.m
as described in arXiv:1402.0939.- Parameters
- tensor_listlist of
Array
The tensors to be contracted.
- leg_contractionslist of
[n1, l1, n2, l2]
A list of contraction instructions. An entry of leg_contractions has the form
[n1, l1, n2, l2]
, wheren1, n2
are entries of tensor_names and each identify anArray
in tensor_list.l1, l2
are leg labels of the correspondingArray
. The instruction implies to contract legl1
of tensorn1
with legl2
of tensorn2
.- open_legslist of
[n1, l1, l]
A list of instructions for “open” (uncontracted) legs.
[n1, l1, l]
implies that legl1
of tensorn1
is not contracted and is labelledl
in the result.- tensor_nameslist 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, ...
.- sequencelist 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
- tensor_listlist of
- Returns
- result
Array
| complex The number or tensor resulting from the contraction.
- result