qiskit-documentation/docs/api/qiskit/0.35/qiskit.circuit.library.XGat...

157 lines
3.4 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
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.20/qiskit/circuit/library/standard_gates/x.py" signature="XGate(label=None)" modifiers="class">
Bases: `qiskit.circuit.gate.Gate`
The single-qubit Pauli-X gate ($\sigma_x$).
**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.
## Methods Defined Here
### control
<Function id="qiskit.circuit.library.XGate.control" signature="XGate.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*) number of control qubits.
* **label** (*str or None*) An optional label for the gate \[Default: None]
* **ctrl\_state** (*int or str 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="XGate.inverse()">
Return inverted X gate (itself).
</Function>
## Attributes
### condition\_bits
<Attribute id="qiskit.circuit.library.XGate.condition_bits">
Get Clbits in condition.
**Return type**
`List`\[`Clbit`]
</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
**Return type**
`str`
</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>
</Class>