ncon

tenpy.algorithms.network_contractor.ncon(tensor_list, leg_links, sequence=None)[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_list (iterable of :class:'Array') – Tensors to be contracted.

  • leg_links (iterable of iterable of int) – Each entry of leg_links describes the connectivity of the corresponding tensor in tensor_list. Each entry is a sequence (e.g. a list) that has an integer value for each leg of the corresponding tensor. Positive values 1,2,... are labels of contracted legs and should appear exactly twice in leg_links. Negative values -1,-2,-3,... are labels of uncontracted legs and indicate the final ordering (-1 is the first axis).

  • sequence (list of int, optional) – The order in which the contractions (indicated by positive values in leg_links) are to be performed. Ascending order is used by default.

Returns:

result – The number or tensor resulting from the contraction.

Return type:

Array | complex