151 lines
3.8 KiB
Plaintext
151 lines
3.8 KiB
Plaintext
---
|
||
title: XGate
|
||
description: API reference for qiskit.circuit.library.XGate
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit.circuit.library.XGate
|
||
---
|
||
|
||
# XGate
|
||
|
||
<Class id="qiskit.circuit.library.XGate" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.25/qiskit/circuit/library/standard_gates/x.py" signature="qiskit.circuit.library.XGate(label=None)" modifiers="class">
|
||
Bases: [`Gate`](qiskit.circuit.Gate "qiskit.circuit.gate.Gate")
|
||
|
||
The single-qubit Pauli-X gate ($\sigma_x$).
|
||
|
||
Can be applied to a [`QuantumCircuit`](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit") with the [`x()`](qiskit.circuit.QuantumCircuit#x "qiskit.circuit.QuantumCircuit.x") method.
|
||
|
||
**Matrix Representation:**
|
||
|
||
$$
|
||
\begin{split}X = \begin{pmatrix}
|
||
0 & 1 \\
|
||
1 & 0
|
||
\end{pmatrix}\end{split}
|
||
$$
|
||
|
||
**Circuit symbol:**
|
||
|
||
```python
|
||
┌───┐
|
||
q_0: ┤ X ├
|
||
└───┘
|
||
```
|
||
|
||
Equivalent to a $\pi$ radian rotation about the X axis.
|
||
|
||
<Admonition title="Note" type="note">
|
||
A global phase difference exists between the definitions of $RX(\pi)$ and $X$.
|
||
|
||
$$
|
||
\begin{split}RX(\pi) = \begin{pmatrix}
|
||
0 & -i \\
|
||
-i & 0
|
||
\end{pmatrix}
|
||
= -i X\end{split}
|
||
$$
|
||
</Admonition>
|
||
|
||
The gate is equivalent to a classical bit flip.
|
||
|
||
$$
|
||
\begin{split}|0\rangle \rightarrow |1\rangle \\
|
||
|1\rangle \rightarrow |0\rangle\end{split}
|
||
$$
|
||
|
||
Create new X gate.
|
||
|
||
## Attributes
|
||
|
||
### condition\_bits
|
||
|
||
<Attribute id="qiskit.circuit.library.XGate.condition_bits">
|
||
Get Clbits in condition.
|
||
</Attribute>
|
||
|
||
### decompositions
|
||
|
||
<Attribute id="qiskit.circuit.library.XGate.decompositions">
|
||
Get the decompositions of the instruction from the SessionEquivalenceLibrary.
|
||
</Attribute>
|
||
|
||
### definition
|
||
|
||
<Attribute id="qiskit.circuit.library.XGate.definition">
|
||
Return definition in terms of other basic gates.
|
||
</Attribute>
|
||
|
||
### duration
|
||
|
||
<Attribute id="qiskit.circuit.library.XGate.duration">
|
||
Get the duration.
|
||
</Attribute>
|
||
|
||
### label
|
||
|
||
<Attribute id="qiskit.circuit.library.XGate.label">
|
||
Return instruction label
|
||
</Attribute>
|
||
|
||
### name
|
||
|
||
<Attribute id="qiskit.circuit.library.XGate.name">
|
||
Return the name.
|
||
</Attribute>
|
||
|
||
### num\_clbits
|
||
|
||
<Attribute id="qiskit.circuit.library.XGate.num_clbits">
|
||
Return the number of clbits.
|
||
</Attribute>
|
||
|
||
### num\_qubits
|
||
|
||
<Attribute id="qiskit.circuit.library.XGate.num_qubits">
|
||
Return the number of qubits.
|
||
</Attribute>
|
||
|
||
### params
|
||
|
||
<Attribute id="qiskit.circuit.library.XGate.params">
|
||
return instruction params.
|
||
</Attribute>
|
||
|
||
### unit
|
||
|
||
<Attribute id="qiskit.circuit.library.XGate.unit">
|
||
Get the time unit of duration.
|
||
</Attribute>
|
||
|
||
## Methods
|
||
|
||
### control
|
||
|
||
<Function id="qiskit.circuit.library.XGate.control" signature="control(num_ctrl_qubits=1, label=None, ctrl_state=None)">
|
||
Return a (multi-)controlled-X gate.
|
||
|
||
One control returns a CX gate. Two controls returns a CCX gate.
|
||
|
||
**Parameters**
|
||
|
||
* **num\_ctrl\_qubits** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.12)")) – number of control qubits.
|
||
* **label** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.12)") *or None*) – An optional label for the gate \[Default: None]
|
||
* **ctrl\_state** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.12)") *or*[*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.12)") *or None*) – control state expressed as integer, string (e.g. ‘110’), or None. If None, use all 1s.
|
||
|
||
**Returns**
|
||
|
||
controlled version of this gate.
|
||
|
||
**Return type**
|
||
|
||
[ControlledGate](qiskit.circuit.ControlledGate "qiskit.circuit.ControlledGate")
|
||
</Function>
|
||
|
||
### inverse
|
||
|
||
<Function id="qiskit.circuit.library.XGate.inverse" signature="inverse()">
|
||
Return inverted X gate (itself).
|
||
</Function>
|
||
</Class>
|
||
|