embed_operators
- Graph.embed_operators(operators, dimensions, *, name=None)
Embed operators into a larger Hilbert space.
The size of the Hilbert space is defined by the dimensions argument.
- Parameters
operators (list[tuple[np.ndarray or Tensor, int]] or tuple[np.ndarray or Tensor, int]) – A tuple or a list of tuples that contain pairs of the operators to be embedded and their corresponding positions in the full space. The positions must be non-negative integers less than the length of the dimensions list. The operators must be at least 2D and can contain leading batch dimensions.
dimensions (list[int]) – The dimensions of each subspace.
name (str, optional) – The name of the node.
- Returns
The operators embedded into the full Hilbert space. The dimension of the Hilbert space of the output is equal to the product of the elements of the dimensions list.
- Return type
See also
kron
Kronecker product between two objects.
kronecker_product_list
Kronecker product of a list of operators.
pauli_kronecker_product
Embed Pauli matrices into a larger Hilbert space.
Examples
Embed a single operator.
>>> sigma_z = graph.pauli_matrix("Z") >>> graph.embed_operators((sigma_z, 0), [2, 3], name="Z0") <Tensor: name="Z0", operation_name="embed_operators", shape=(6, 6)> >>> result = qctrl.functions.calculate_graph( ... graph=graph, output_node_names=["Z0"] ... ) >>> result.output["Z0"]["value"] array([[ 1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j], [ 0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j], [ 0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j], [ 0.+0.j, 0.+0.j, 0.+0.j, -1.+0.j, 0.+0.j, 0.+0.j], [ 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, -1.+0.j, 0.+0.j], [ 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, -1.+0.j]])
Embed multiple operators.
>>> number_op = graph.number_operator(2) >>> sigma_x = graph.pauli_matrix("X") >>> graph.embed_operators([(number_op, 0), (sigma_x, 2)], [2, 2, 2], name="N0X2") <Tensor: name="N0X2", operation_name="embed_operators", shape=(8, 8)> >>> result = qctrl.functions.calculate_graph( ... graph=graph, output_node_names=["N0X2"] ... ) >>> result.output["N0X2"]["value"] array([[0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j], [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j], [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j], [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j], [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j], [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j], [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j], [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j]])