# inner_product

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

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

Calculate the inner product of two vectors.

The vectors must have the same last dimension and broadcastable shapes.

### 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 `(..., D)`.
* **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 `(..., D)`.
* **name** (*str* *or* *None* *,* *optional*) – The name of the node.
### Returns
The inner product of two vectors of shape `(...)`.
### 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.einsum`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/einsum.md#boulderopal.graph.Graph.einsum)
: Tensor contraction via Einstein summation convention.

[`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.outer_product`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/outer_product.md#boulderopal.graph.Graph.outer_product)
: Outer 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 inner product or dot product of two complex vectors $\mathbf{x}$
and $\mathbf{y}$ is defined as

$$
\langle \mathbf{x} \vert \mathbf{y} \rangle = \sum_i x^\ast_{i} y_{i} .
$$

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

## Examples

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

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