# outer_product

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

```python
Graph.outer_product(x, y, *, name=None)
```

Calculate the outer product of two vectors.

The vectors can have different last dimensions but must have broadcastable batch dimensions.

### Parameters
* **x** (*np.ndarray* *or* [*Tensor*](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Tensor.md#boulderopal.graph.Tensor)) – The left multiplicand. It must be a vector of shape `(..., M)`.
* **y** (*np.ndarray* *or* [*Tensor*](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Tensor.md#boulderopal.graph.Tensor)) – The right multiplicand. It must be a vector of shape `(..., N)`.
* **name** (*str* *or* *None* *,* *optional*) – The name of the node.
### Returns
The outer product of two vectors of shape `(..., M, N)`.
### Return type
[Tensor](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Tensor.md#boulderopal.graph.Tensor)

### SEE ALSO
[`Graph.density_matrix_expectation_value`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/density_matrix_expectation_value.md#boulderopal.graph.Graph.density_matrix_expectation_value)
: Expectation value of an operator with respect to a density matrix.

[`Graph.expectation_value`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/expectation_value.md#boulderopal.graph.Graph.expectation_value)
: Expectation value of an operator with respect to a pure state.

[`Graph.inner_product`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/inner_product.md#boulderopal.graph.Graph.inner_product)
: Inner product of two vectors.

[`Graph.trace`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/trace.md#boulderopal.graph.Graph.trace)
: Trace of an object.

## Notes

The outer product of two complex vectors $\mathbf{x}$
and $\mathbf{y}$ is defined as

$$
(\mathbf{x} \otimes \mathbf{y})_{ij} = x_{i} y^\ast_{j}.
$$

For more information about the outer product, see [outer product](https://en.wikipedia.org/wiki/Outer_product) on Wikipedia.

## Examples

```pycon
>>> graph.outer_product(np.array([1j, 1j]), np.array([1j, -1j]), name="outer")
<Tensor: name="outer", operation_name="outer_product", shape=(2, 2)>
>>> result = bo.execute_graph(graph=graph, output_node_names="outer")
>>> result["output"]["outer"]["value"]
array([[1.+0.j, -1.+0.j], [1.+0.j, -1.+0.j]])
```

```pycon
>>> graph.outer_product(np.ones((3,1,2), np.ones(2,2), name="outer2")
<Tensor: name="outer2", operation_name="outer_product", shape=(3, 2, 2, 2)>
>>> result = bo.execute_graph(graph=graph, output_node_names="outer2")
>>> result["output"]["outer2"]["value"]
array([[[[1, 1], [1, 1]], [[1, 1], [1, 1]]],
    [[[1, 1], [1, 1]], [[1, 1], [1, 1]]],
    [[[1, 1], [1, 1]], [[1, 1], [1, 1]]])
```
