ncon

tenpy.algorithms.network_contractor.ncon(tensor_list, leg_links, sequence)[source]

Implementation of ncon.m for TeNPy Arrays.

This function is a python implementation of ncon.m (arXiv:1304.6112) for tenpy Array. contract() is a wrapper that translates from a more python/tenpy input style

Parameters
tensor_listlist of :class:’Array’

Tensors to be contracted.

leg_linkslist of list of int

Each entry of leg_links describes the connectivity of the corresponding tensor in tensor_list. Each entry is a list that has an entry for each leg of the corresponding tensor. Values 0,1,2,... are labels of contracted legs and should appear exactly twice in leg_links. Values -1,-2,-3,... are labels of uncontracted legs and indicate the final ordering (-1 is first axis).

sequencelist of int

The order in which the 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

Returns
resultArray | complex

The number or tensor resulting from the contraction.