---
title: InnerProduct (latest version)
description: API reference for qiskit.circuit.library.InnerProduct in the latest version of qiskit
source: https://eu-de.quantum.cloud.ibm.com/docs/en/api/qiskit/qiskit.circuit.library.InnerProduct
---

# InnerProduct

*class* `qiskit.circuit.library.InnerProduct(num_qubits)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.5/qiskit/circuit/library/boolean_logic/inner_product.py#L21-L84)

Bases: [`QuantumCircuit`](/docs/api/qiskit/qiskit.circuit.QuantumCircuit "qiskit.circuit.quantumcircuit.QuantumCircuit")

A 2n-qubit Boolean function that computes the inner product of two n-qubit vectors over $F_2$.

This implementation is a phase oracle which computes the following transform.

$$
\mathcal{IP}_{2n} : F_2^{2n} \rightarrow {-1, 1}
\mathcal{IP}_{2n}(x_1, \cdots, x_n, y_1, \cdots, y_n) = (-1)^{x.y}
$$

The corresponding unitary is a diagonal, which induces a -1 phase on any inputs where the inner product of the top and bottom registers is 1. Otherwise it keeps the input intact.

```text
q0_0: ─■──────────
       │
q0_1: ─┼──■───────
       │  │
q0_2: ─┼──┼──■────
       │  │  │
q0_3: ─┼──┼──┼──■─
       │  │  │  │
q1_0: ─■──┼──┼──┼─
          │  │  │
q1_1: ────■──┼──┼─
             │  │
q1_2: ───────■──┼─
                │
q1_3: ──────────■─
```

**Reference Circuit:**

![Diagram illustrating the previously described circuit.](https://eu-de.quantum.cloud.ibm.com/docs/images/api/qiskit/qiskit-circuit-library-InnerProduct-1.avif)

> **Deprecated since version 2.1**
>
> The class `qiskit.circuit.library.boolean_logic.inner_product.InnerProduct` is deprecated as of Qiskit 2.1. It will be removed in Qiskit 3.0. Use qiskit.circuit.library.InnerProductGate instead.

**Parameters**

**num\_qubits** ([*int*](https://docs.python.org/3/library/functions.html#int)) – width of top and bottom registers (half total circuit width)

## Attributes

### name

Type: `str`

A human-readable name for the circuit.

**Example**

```python
from qiskit import QuantumCircuit

qc = QuantumCircuit(2, 2, name="my_circuit")
print(qc.name)
```

```text
my_circuit
```
