qiskit-documentation/docs/api/qiskit/0.44/qiskit.circuit.library.UGat...

145 lines
4.2 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: UGate
description: API reference for qiskit.circuit.library.UGate
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.circuit.library.UGate
---
# UGate
<Class id="qiskit.circuit.library.UGate" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.25/qiskit/circuit/library/standard_gates/u.py" signature="qiskit.circuit.library.UGate(theta, phi, lam, label=None)" modifiers="class">
Bases: [`Gate`](qiskit.circuit.Gate "qiskit.circuit.gate.Gate")
Generic single-qubit rotation gate with 3 Euler angles.
Can be applied to a [`QuantumCircuit`](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit") with the [`u()`](qiskit.circuit.QuantumCircuit#u "qiskit.circuit.QuantumCircuit.u") method.
**Circuit symbol:**
```python
┌──────────┐
q_0: ┤ U(ϴ,φ,λ) ├
└──────────┘
```
**Matrix Representation:**
$$
\begin{align}\begin{aligned}\newcommand{\th}{\frac{\theta}{2}}\\\begin{split}U(\theta, \phi, \lambda) =
\begin{pmatrix}
\cos\left(\th\right) & -e^{i\lambda}\sin\left(\th\right) \\
e^{i\phi}\sin\left(\th\right) & e^{i(\phi+\lambda)}\cos\left(\th\right)
\end{pmatrix}\end{split}\end{aligned}\end{align}
$$
<Admonition title="Note" type="note">
The matrix representation shown here is the same as in the [OpenQASM 3.0 specification](https://openqasm.com/language/gates.html#built-in-gates), which differs from the [OpenQASM 2.0 specification](https://doi.org/10.48550/arXiv.1707.03429) by a global phase of $e^{i(\phi+\lambda)/2}$.
</Admonition>
**Examples:**
$$
U\left(\theta, -\frac{\pi}{2}, \frac{\pi}{2}\right) = RX(\theta)
$$
$$
U(\theta, 0, 0) = RY(\theta)
$$
Create new U gate.
## Attributes
### condition\_bits
<Attribute id="qiskit.circuit.library.UGate.condition_bits">
Get Clbits in condition.
</Attribute>
### decompositions
<Attribute id="qiskit.circuit.library.UGate.decompositions">
Get the decompositions of the instruction from the SessionEquivalenceLibrary.
</Attribute>
### definition
<Attribute id="qiskit.circuit.library.UGate.definition">
Return definition in terms of other basic gates.
</Attribute>
### duration
<Attribute id="qiskit.circuit.library.UGate.duration">
Get the duration.
</Attribute>
### label
<Attribute id="qiskit.circuit.library.UGate.label">
Return instruction label
</Attribute>
### name
<Attribute id="qiskit.circuit.library.UGate.name">
Return the name.
</Attribute>
### num\_clbits
<Attribute id="qiskit.circuit.library.UGate.num_clbits">
Return the number of clbits.
</Attribute>
### num\_qubits
<Attribute id="qiskit.circuit.library.UGate.num_qubits">
Return the number of qubits.
</Attribute>
### params
<Attribute id="qiskit.circuit.library.UGate.params">
return instruction params.
</Attribute>
### unit
<Attribute id="qiskit.circuit.library.UGate.unit">
Get the time unit of duration.
</Attribute>
## Methods
### control
<Function id="qiskit.circuit.library.UGate.control" signature="control(num_ctrl_qubits=1, label=None, ctrl_state=None)">
Return a (multi-)controlled-U 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.UGate.inverse" signature="inverse()">
Return inverted U gate.
$U(\theta,\phi,\lambda)^{\dagger} =U(-\theta,-\lambda,-\phi)$)
</Function>
</Class>