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)

Barrier appearance

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()

Measure appearance

Reset

The Reset class creates a reset instruction that reset the qubit state to vertical-bar 0 mathematical right-angle (see “Using the reset() method”).

Signature:

Appearance:

Reset()

Reset appearance

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 vertical-bar 0 mathematical right-angle,vertical-bar 1 mathematical right-angle to vertical-bar plus mathematical right-angle,vertical-bar minus mathematical right-angle and vice-versa.

Signature:

Appearance:

Matrix:

HGate(label=None)

HGate appearance

StartFraction 1 Over StartRoot 2 EndRoot EndFraction Start 2 By 2 Matrix 1st Row 1st Column 1 2nd Column 1 2nd Row 1st Column 1 2nd Column negative 1 EndMatrix

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)

IGate appearance

Start 2 By 2 Matrix 1st Row 1st Column 1 2nd Column 0 2nd Row 1st Column 0 2nd Column 1 EndMatrix

PhaseGate

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

Signature:

Appearance:

Matrix:

PhaseGate(theta, label=None)

PhaseGate appearance

Start 2 By 2 Matrix 1st Row 1st Column 1 2nd Column 0 2nd Row 1st Column 0 2nd Column e Superscript i lamda EndMatrix

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)

RXGate appearance

Start 2 By 2 Matrix 1st Row 1st Column cosine StartFraction theta Over 2 EndFraction 2nd Column minus i sine StartFraction theta Over 2 EndFraction 2nd Row 1st Column minus i sine StartFraction theta Over 2 EndFraction 2nd Column cosine StartFraction theta Over 2 EndFraction EndMatrix

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)

RYGate appearance

Start 2 By 2 Matrix 1st Row 1st Column cosine StartFraction theta Over 2 EndFraction 2nd Column minus sine StartFraction theta Over 2 EndFraction 2nd Row 1st Column sine StartFraction theta Over 2 EndFraction 2nd Column cosine StartFraction theta Over 2 EndFraction EndMatrix

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)

RZGate appearance

Start 2 By 2 Matrix 1st Row 1st Column e Superscript minus i StartFraction lamda Over 2 EndFraction 2nd Column 0 2nd Row 1st Column 0 2nd Column e Superscript i StartFraction lamda Over 2 EndFraction EndMatrix

SGate

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

Signature:

Appearance:

Matrix:

SGate(label=None)

SGate appearance

Start 2 By 2 Matrix 1st Row 1st Column 1 2nd Column 0 2nd Row 1st Column 0 2nd Column i EndMatrix

SdgGate

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

Signature:

Appearance:

Matrix:

SdgGate(label=None)

SdgGate appearance

Start 2 By 2 Matrix 1st Row 1st Column 1 2nd Column 0 2nd Row 1st Column 0 2nd Column negative i EndMatrix

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)

SXGate appearance

one-half Start 2 By 2 Matrix 1st Row 1st Column 1 plus i 2nd Column 1 minus i 2nd Row 1st Column 1 minus i 2nd Column 1 plus i EndMatrix

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)

SXdgGate appearance

one-half Start 2 By 2 Matrix 1st Row 1st Column 1 minus i 2nd Column 1 plus i 2nd Row 1st Column 1 plus i 2nd Column 1 minus i EndMatrix

TGate

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

Signature:

Appearance:

Matrix:

TGate(label=None)

TGate appearance

Start 2 By 2 Matrix 1st Row 1st Column 1 2nd Column 0 2nd Row 1st Column 0 2nd Column e Superscript i pi slash 4 EndMatrix

TdgGate

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

Signature:

Appearance:

Matrix:

TdgGate(label=None)

TdgGate appearance

Start 2 By 2 Matrix 1st Row 1st Column 1 2nd Column 0 2nd Row 1st Column 0 2nd Column e Superscript minus i pi slash 4 EndMatrix

UGate

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

Signature:

Appearance:

Matrix:

UGate(theta, phi, lam, label=None)

UGate appearance

XGate

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

Signature:

Appearance:

Matrix:

XGate(label=None)

XGate appearance

Start 2 By 2 Matrix 1st Row 1st Column 0 2nd Column 1 2nd Row 1st Column 1 2nd Column 0 EndMatrix

YGate

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

Signature:

Appearance:

Matrix:

YGate(label=None)

YGate appearance

Start 2 By 2 Matrix 1st Row 1st Column 0 2nd Column negative i 2nd Row 1st Column i 2nd Column 0 EndMatrix

ZGate

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

Signature:

Appearance:

Matrix:

ZGate(label=None)

ZGate appearance

Start 2 By 2 Matrix 1st Row 1st Column 1 2nd Column 0 2nd Row 1st Column 0 2nd Column negative 1 EndMatrix

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)

C3XGate appearance

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)

C3SXGate appearance

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)

C4XGate appearance

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)

CCXGate appearance

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)

CHGate appearance

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)

CPhaseGate appearance

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)

CRXGate appearance

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)

CRYGate appearance

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)

CRZGate appearance

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)

CSwapGate appearance

CSXGate

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

Signature:

Appearance:

CSXGate(label=None, ctrl_state=None)

CSXGate appearance

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)

CUGate appearance

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)

CXGate appearance

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)

CYGate appearance

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)

CZGate appearance

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()

DCXGate appearance

iSwapGate

The iSwapGate class swaps the qubit states of two quantum wires. It also changes the phase of vertical-bar 01 mathematical right-angle and vertical-bar 10 mathematical right-angle amplitudes by i.

Signature:

Appearance:

iSwapGate(label=None, ctrl_state=None)

iSwapGate appearance

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)

MCPhaseGate appearance

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)

MCXGate appearance

SwapGate

The SwapGate swaps the qubit states of two quantum wires.

Signature:

Appearance:

SwapGate(label=None)

SwapGate appearance

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset