# embed_operators

Source: https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/embed_operators

```python
Graph.embed_operators(operators, dimensions, *, name=None)
```

Embed an operator or set of operators into a larger Hilbert space.

### Parameters
* **operators** (*list* *[* *tuple* *[* *np.ndarray* *or* [*Tensor*](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Tensor.md#boulderopal.graph.Tensor) *,* *int* *]* *] or* *tuple* *[* *np.ndarray* *or* [*Tensor*](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Tensor.md#boulderopal.graph.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.
  The dimension of the operators must match the value of the dimensions list
  at the given position.
* **dimensions** (*list* *[* *int* *]*) – The dimensions of each subspace.
* **name** (*str* *or* *none* *,* *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
[Tensor](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Tensor.md#boulderopal.graph.Tensor)

### SEE ALSO
[`Graph.kron`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/kron.md#boulderopal.graph.Graph.kron)
: Kronecker product between two objects.

[`Graph.kronecker_product_list`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/kronecker_product_list.md#boulderopal.graph.Graph.kronecker_product_list)
: Kronecker product of a list of operators.

[`Graph.pauli_kronecker_product`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/pauli_kronecker_product.md#boulderopal.graph.Graph.pauli_kronecker_product)
: Embed Pauli matrices into a larger Hilbert space.

## Notes

This function computes $A_1 \otimes A_2 \otimes ...$ where $A_i$
is either the operator passed for position $i$ (if given) or an identity matrix.
The dimension of $A_i$ corresponds to the $i$-th entry in the dimensions list.

## Examples

Embed a single operator.

```pycon
>>> 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 = bo.execute_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.

```pycon
>>> 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 = bo.execute_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]])
```
