tensorcircuit.simplify#
Tensornetwork Simplification
- tensorcircuit.simplify.infer_new_shape(a: tensornetwork.network_components.Node, b: tensornetwork.network_components.Node, include_old: bool = True) Any [source]#
Get the new shape of two nodes, also supporting to return original shapes of two nodes.
- Example
>>> a = tn.Node(np.ones([2, 3, 5])) >>> b = tn.Node(np.ones([3, 5, 7])) >>> a[1] ^ b[0] >>> a[2] ^ b[1] >>> tc.simplify.infer_new_shape(a, b) >>> ((2, 7), (2, 3, 5), (3, 5, 7)) >>> # (shape of a, shape of b, new shape)
- Parameters
a (tn.Node) – node one
b (tn.Node) – node two
include_old (bool) – Whether to include original shape of two nodes, default is True.
- Returns
The new shape of the two nodes.
- Return type
Union[Tuple[int, …], Tuple[Tuple[int, …], Tuple[int, …], Tuple[int, …]]]
- tensorcircuit.simplify.infer_new_size(a: tensornetwork.network_components.Node, b: tensornetwork.network_components.Node, include_old: bool = True) Any [source]#
- tensorcircuit.simplify.pseudo_contract_between(a: tensornetwork.network_components.Node, b: tensornetwork.network_components.Node, **kws: Any) tensornetwork.network_components.Node [source]#
Contract between Node
a
andb
, with correct shape only and no calculation- Parameters
a (tn.Node) – [description]
b (tn.Node) – [description]
- Returns
[description]
- Return type
tn.Node