# qiskit.circuit.library.boolean_logic.inner_product のソースコード

# This code is part of Qiskit.
#
#
# obtain a copy of this license in the LICENSE.txt file in the root directory
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""InnerProduct circuit."""

from qiskit.circuit import QuantumRegister, QuantumCircuit

[ドキュメント]class InnerProduct(QuantumCircuit):
"""An n_qubit circuit that computes the inner product of two registers."""

[ドキュメント]    def __init__(self, num_qubits: int) -> None:
"""Return a circuit to compute the inner product of 2 n-qubit registers.

This implementation uses CZ gates.

Args:
num_qubits: width of top and bottom registers (half total circuit width)

Reference Circuit:
.. jupyter-execute::
:hide-code:

from qiskit.circuit.library import InnerProduct
import qiskit.tools.jupyter
circuit = InnerProduct(5)
%circuit_library_info circuit
"""
qr_a = QuantumRegister(num_qubits)
qr_b = QuantumRegister(num_qubits)
super().__init__(qr_a, qr_b, name="inner_product")

for i in range(num_qubits):
self.cz(qr_a[i], qr_b[i])