qib.tensor_network.tensor_network.TensorNetwork

class qib.tensor_network.tensor_network.TensorNetwork(net: SymbolicTensorNetwork, data: dict)[source]

Bases: object

Tensor network, consisting of a symbolic network representation, and a dictionary storing the tensor entries addressed by the dataref member variable of the tensors.

Methods

contract_einsum

Contract the overall network by a single call of np.einsum.

contract_tree

Contract the overall network based on the contraction tree specified by scaffold.

is_consistent

Perform an internal consistency check, e.g., whether the bond ID specified by any tensor actually exist.

merge

Merge network with another tensor network, and join open axes specified as [(openax_self, openax_other), ...].

transpose

Logically transpose the network, i.e., the virtual output tensor of the network.

wrap

Wrap a single tensor, i.e., construct a tensor network representation of the tensor.

Attributes

num_bonds

Number of bonds.

num_open_axes

Number of open (uncontracted) axes in the network.

num_tensors

Number of logical tensors.

shape

Logical shape of tensor network (after contracting all bonds).

contract_einsum()[source]

Contract the overall network by a single call of np.einsum.

contract_tree(scaffold)[source]

Contract the overall network based on the contraction tree specified by scaffold.

is_consistent(verbose=False) bool[source]

Perform an internal consistency check, e.g., whether the bond ID specified by any tensor actually exist.

merge(other, join_axes: Sequence[tuple] | None = None)[source]

Merge network with another tensor network, and join open axes specified as [(openax_self, openax_other), …].

property num_bonds: int

Number of bonds.

property num_open_axes: int

Number of open (uncontracted) axes in the network.

property num_tensors: int

Number of logical tensors.

property shape: tuple

Logical shape of tensor network (after contracting all bonds).

transpose(axes=None)[source]

Logically transpose the network, i.e., the virtual output tensor of the network.

classmethod wrap(a: ndarray, dataref)[source]

Wrap a single tensor, i.e., construct a tensor network representation of the tensor.