Skip to main contentIBM Quantum Documentation Mirror

InnerProduct

class qiskit.circuit.library.InnerProduct(num_qubits)

GitHub

Bases: QuantumCircuit

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

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

IP2n:F22n1,1IP2n(x1,,xn,y1,,yn)=(1)x.y\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.

q0_0: ─■──────────

q0_1: ─┼──■───────
       │  │
q0_2: ─┼──┼──■────
       │  │  │
q0_3: ─┼──┼──┼──■─
       │  │  │  │
q1_0: ─■──┼──┼──┼─
          │  │  │
q1_1: ────■──┼──┼─
             │  │
q1_2: ───────■──┼─

q1_3: ──────────■─

Reference Circuit:

Diagram illustrating the previously described circuit.

Return a circuit to compute the inner product of 2 n-qubit registers.

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) – width of top and bottom registers (half total circuit width)


Attributes

name

Type: str

A human-readable name for the circuit.

Example

from qiskit import QuantumCircuit
 
qc = QuantumCircuit(2, 2, name="my_circuit")
print(qc.name)
my_circuit