quri_parts.tensornetwork.operator package¶
- class TensorNetworkOperator(input_edges, output_edges, container, layer_tensor_map)¶
Bases:
TensorNetworkLayerTensor network representation of a operators.
This class subclasses
TensorNetworkLayerand provides, in addition to input and output edges for the operator, also a list of indices that the operator acts on. These indices are defined with respect to some quantum state that the operator is intended to act on. The intent is to allow for certain optimizations with tensor contraction.- Parameters:
input_edges (Sequence[Edge])
output_edges (Sequence[Edge])
container (Union[set[AbstractNode], list[AbstractNode]])
layer_tensor_map (list[dict[int, AbstractNode]])
- copy()¶
Returns a copy of itself.
- Return type:
- contract_with(state)¶
- Parameters:
state (TensorNetworkState)
- Return type:
AbstractNode
- get_observable_data(pauli_list, dim=2, n=None)¶
Take a list of matrices that represent pauli operators and calculate their tensor-product.
- Parameters:
pauli_list (Sequence[Sequence[Sequence[complex]]])
dim (int)
n (int | None)
- Return type:
ndarray[Any, dtype[complex128]]
- pauli_label_to_array(pauli, index_list=None)¶
Convert a
PauliLabelto a numpy array.If this function is used to convert a
PauliLabelbelonging to anOperator, then an index_list, describing all of the indices acted on by theOperator, should be passed as an argument. The returned array will then be padded with identity operators where needed.- Parameters:
pauli (PauliLabel)
index_list (Collection[int] | None)
- Return type:
ndarray[Any, dtype[complex128]]
- tensor_to_mpo(operator, max_bond_dimension=None, max_truncation_err=None, qubits_per_node=1)¶
Perform the singular value decomposition on an operator represented using
TensorNetworkLayerand return the matrix product operator (MPO) as aTensorNetworkLayer- Parameters:
operator (TensorNetworkOperator) – Input operator
max_bond_dimension (int | None) – Optional specification of MPO bond-dimension
max_truncation_error – Optional specification of truncation error tolerance
qubits_per_node (int) – Number of physical qubits attached to each node, defaults to 1
max_truncation_err (float | None)
- Return type:
- Outputs:
MPO as a
TensorNetworkOperator
- operator_to_tensor(operator, convert_to_mpo=True, backend='numpy', *args, **kwargs)¶
Convert an
Operatoror aPauliLabelto aTensorNetworkOperator.- Parameters:
operator (Operator | PauliLabel) – Input operator
convert_to_mpo (bool) – Whether or not to convert the operator to an MPO
backend (str) – Backend to use for tensor operations
args (Any)
kwargs (Any)
- Keyword Arguments:
max_bond_dimension – if convert_to_mpo is true, this sets the maximum bond dimension
max_truncation_err – if convert_to_mpo is true, this sets the maximum truncation error
- Return type:
- Outputs:
Operator as a
TensorNetworkOperator
- pauli_label_to_tensor(pl, backend='numpy', coefficient=None)¶
- Parameters:
pl (PauliLabel)
backend (str)
coefficient (complex | None)
- Return type:
- operator_to_tensor_sequence(operator, backend='numpy')¶
Returns a sequence of TensorNetworkOperator each corresponding to a single PauliLabel.
Each generated operator has a trivial bond dimension.
- Parameters:
operator (Operator | PauliLabel) – Input operator
backend (str) – Backend to use for tensor operations
- Return type:
Sequence[TensorNetworkOperator]
- Outputs:
Operator as a
TensorNetworkOperator