Skip to main content
IBM Quantum Platform

XOR

class qiskit.circuit.library.XOR(num_qubits, amount=None, seed=None)

GitHub

Bases: QuantumCircuit

An n_qubit circuit for bitwise xor-ing the input with some integer amount.

The amount is xor-ed in bitstring form with the input.

This circuit can also represent addition by amount over the finite field GF(2).

Deprecated since version 2.1

The class qiskit.circuit.library.boolean_logic.quantum_xor.XOR is deprecated as of Qiskit 2.1. It will be removed in Qiskit 3.0. Instead, for xor-ing with a specified amount, use BitwiseXorGate,and for xor-ing with a random amount, use random_bitwise_xor.

Parameters

  • num_qubits (int) – the width of circuit.
  • amount (int | None) – the xor amount in decimal form.
  • seed (int | None) – random seed in case a random xor is requested.

Raises

CircuitError – if the xor bitstring exceeds available qubits.

Reference Circuit:

Diagram illustrating the previously described circuit.

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
Was this page helpful?
Report a bug, typo, or request content on GitHub.