 • Search in book...
• Toggle Font Controls

# Chapter 2. Qiskit Circuit Library Standard Operations

The Qiskit Circuit Library contains many operations and circuits that may be used as building blocks for implementing quantum algorithms. Here are some standard operations categorized as instructions, single-qubit gates, and multi-qubit gates.

# Standard Instructions

The standard instruction classes implement quantum operations that aren’t necessarily unitary. They are subclasses of the `Instruction` class (see “The Instruction Class”).

## Barrier

The `Barrier` class creates a barrier instruction (see “Creating a Barrier”) with a given number of qubits. A barrier provides both visual and functional separation between gates on a wire in a quantum circuit.

 Signature: Appearance: `Barrier(num_qubits)` ## Measure

The `Measure` class creates a measurement instruction for measuring a quantum state in the computational basis, placing the binary result in a classical register (see “Measuring a quantum circuit”).

 Signature: Appearance: `Measure()` ## Reset

The `Reset` class creates a reset instruction that reset the qubit state to (see “Using the reset() method”).

 Signature: Appearance: `Reset()` # Standard Single-Qubit Gates

The standard single-qubit gates implement unitary quantum operations. They are subclasses of the `Gate` class (see “The Gate Class”). These gates may be created and applied to a circuit via the single-qubit gate methods of the `QuantumCircuit` class that appear in Table 1-1.

## HGate

The `HGate` class creates a single-qubit H gate. It performs a π rotation around the X+Z axis. It also has the effect of changing the computational basis from , to , and vice-versa.

 Signature: Appearance: Matrix: `HGate(label=None)`  ## IGate

The `IGate` class creates a single-qubit I gate, which has no effect on the state of a qubit.

 Signature: Appearance: Matrix: `IGate(label=None)`  ## PhaseGate

The `PhaseGate` class creates a single-qubit Phase gate that performs a given phase rotation.

 Signature: Appearance: Matrix: `PhaseGate(theta, label=None)`  ## RXGate

The `RXGate` class creates a single-qubit RX gate that performs a given rotation around the X axis.

 Signature: Appearance: Matrix: `RXGate(theta, label=None)`  ## RYGate

The `RYGate` class creates a single-qubit RY gate that performs a given rotation around the Y axis.

 Signature: Appearance: Matrix: `RYGate(theta, label=None)`  ## RZGate

The `RZGate` class creates a single-qubit RZ gate that performs a given rotation around the Z axis.

 Signature: Appearance: Matrix: `RZGate(phi, label=None)`  ## SGate

The `SGate` class creates a single-qubit S gate that performs a π/2 phase rotation.

 Signature: Appearance: Matrix: `SGate(label=None)`  ## SdgGate

The `SdgGate` class creates a single-qubit S† gate that performs a -π/2 phase rotation.

 Signature: Appearance: Matrix: `SdgGate(label=None)`  ## SXGate

The `SXGate` class creates a single-qubit square root of X gate that performs a π/2 rotation around the X axis while shifting the global phase by π/4.

 Signature: Appearance: Matrix: `SXGate(label=None)`  ## SXdgGate

The `SXdgGate` class creates a single-qubit inverse square root of X gate that performs a -π/2 rotation around the X axis while shifting the global phase by -π/4.

 Signature: Appearance: Matrix: `SXdgGate(label=None)`  ## TGate

The `TGate` class creates a single-qubit T gate that performs a π/4 phase rotation.

 Signature: Appearance: Matrix: `TGate(label=None)`  ## TdgGate

The `TdgGate` class creates a single-qubit T† gate that performs a -π/4 phase rotation.

 Signature: Appearance: Matrix: `TdgGate(label=None)`  ## UGate

The `UGate` class creates a single-qubit U gate with 3 Euler angles.

 Signature: Appearance: Matrix: `UGate(theta, phi, lam, label=None)`  ## XGate

The `XGate` class creates a single-qubit X gate that performs a π rotation around the X axis.

 Signature: Appearance: Matrix: `XGate(label=None)`  ## YGate

The `YGate` class creates a single-qubit Y gate that performs a π rotation around the Y axis.

 Signature: Appearance: Matrix: `YGate(label=None)`  ## ZGate

The `ZGate` class creates a single-qubit Z gate that performs a π rotation around the Z axis.

 Signature: Appearance: Matrix: `ZGate(label=None)`  # Standard Multi-Qubit Gates

The standard multi-qubit gates implement unitary quantum operations. They are subclasses of the `ControlledGate` class (see “The ControlledGate Class”). Some of these gates may be created and applied to a circuit via the multi-qubit gate methods of the `QuantumCircuit` class, many of which appear in Table 1-2.

## C3XGate

The `C3XGate` class creates a four-qubit gate that has an X gate and three control qubits.

 Signature: Appearance: `C3XGate(angle=None, label=None, ctrl_state=None)` ## C3SXGate

The `C3SXGate` class creates a four-qubit gate that has a square root of X gate and three control qubits.

 Signature: Appearance: `C3SXGate(label=None, ctrl_state=None, *, angle=None)` ## C4XGate

The `C4XGate` class creates a five-qubit gate that has an X gate and four control qubits.

 Signature: Appearance: `C4XGate(label=None, ctrl_state=None)` ## CCXGate

The `CCXGate` class creates a three-qubit gate that has an X gate and two control qubits. This is also known as a Toffoli gate.

 Signature: Appearance: `CCXGate(label=None, ctrl_state=None)` ## CHGate

The `CHGate` class creates a controlled-Hadamard gate, applying the Hadamard according to the control qubit state.

 Signature: Appearance: `CHGate(label=None, ctrl_state=None)` ## CPhaseGate

The `CPhaseGate` class creates a controlled-Phase gate, applying the `PhaseGate` according to the control qubit state.

 Signature: Appearance: `CPhaseGate(theta, label=None, ctrl_state=None)` ## CRXGate

The `CRXGate` class creates a controlled-RX gate, applying the `RX` according to the control qubit state.

 Signature: Appearance: `CRXGate(theta, label=None, ctrl_state=None)` ## CRYGate

The `CRYGate` class creates a controlled-RY gate, applying the `RY` according to the control qubit state.

 Signature: Appearance: `CRYGate(theta, label=None, ctrl_state=None)` ## CRZGate

The `CRZGate` class creates a controlled-RZ gate, applying the `RZ` according to the control qubit state.

 Signature: Appearance: `CRZGate(theta, label=None, ctrl_state=None)` ## CSwapGate

The `CSwapGate` class creates a three-qubit gate whose Swap gate is applied according to the control qubit state.

 Signature: Appearance: `CSwapGate(label=None, ctrl_state=None)` ## CSXGate

The `CSXGate` class creates a controlled-SX (square root of X) gate, applying the gate according to the control qubit state.

 Signature: Appearance: `CSXGate(label=None, ctrl_state=None)` ## CUGate

The `CUGate` class creates a controlled-U gate, applying the U gate including a global phase argument, according to the control qubit state.

 Signature: Appearance: `CUGate(theta, phi, lam, gamma, label=None, ctrl_state=None)` ## CXGate

The `CXGate` class creates a controlled-X gate, applying the X gate according to the control qubit state.

 Signature: Appearance: `CXGate(label=None, ctrl_state=None)` ## CYGate

The `CYGate` class creates a controlled-Y gate, applying the Y gate according to the control qubit state.

 Signature: Appearance: `CYGate(label=None, ctrl_state=None)` ## CZGate

The `CZGate` class creates a controlled-Z gate, applying the Z gate according to the control qubit state.

 Signature: Appearance: `CZGate(label=None, ctrl_state=None)` ## DCXGate

The `DCXGate` class creates a double-CNOT gate. This is a two-qubit gate that has two CNOT gates with their control-qubits on different wires.

 Signature: Appearance: `DCXGate()` ## iSwapGate

The `iSwapGate` class swaps the qubit states of two quantum wires. It also changes the phase of and amplitudes by i.

 Signature: Appearance: `iSwapGate(label=None, ctrl_state=None)` ## MCPhaseGate

The `MCPhaseGate` class creates a multi-controlled Phase gate with a given number of control qubits.

 Signature: Appearance: `MCPhaseGate(lam, num_ctrl_qubits, label=None)` ## MCXGate

The `MCXGate` class creates a multi-controlled X gate with a given number of control qubits.

 Signature: Appearance: `MCXGate(num_ctrl_qubits=None, label=None, ctrl_state=None)` ## SwapGate

The `SwapGate` swaps the qubit states of two quantum wires.

 Signature: Appearance: `SwapGate(label=None)` • No Comment
..................Content has been hidden....................