qat.ir.gates.gates_1q module
- class Gate1Q(**data)
Bases:
GateBase
,ABC
Base gate for single qubit operations.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
-
inst:
Literal
['Gate1Q'
]
- abstract property matrix
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'ser_json_inf_nan': 'constants', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
qubit:
Annotated
[int
]
- property qubits
-
inst:
- class Hadamard(**data)
Bases:
Gate1Q
Implements the Hadamard gate \(H\).
Matrix representation:
\[\begin{split}H = \begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}.\end{split}\]Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
-
inst:
Literal
['Hadamard'
]
- property matrix
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'ser_json_inf_nan': 'constants', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
inst:
- class Id(**data)
Bases:
Gate1Q
The identity gate for a single qubit.
Matrix representation:
\[\begin{split}I = \begin{bmatrix}1 & 0 \\ 0 & 1 \end{bmatrix}.\end{split}\]- Parameters:
qubit¶ – Target qubit index.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
-
inst:
Literal
['Id'
]
- property matrix
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'ser_json_inf_nan': 'constants', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class Phase(**data)
Bases:
Gate1Q
The \({\rm Phase}(\theta)\) gate for some rotation angle \(\theta\).
Equivalent to the \(Rz(\theta)\) gate up to a global rotation. Matrix representation:
\[\begin{split}{\rm Phase}(\theta) = \begin{bmatrix} 1 & 0 \\ 0 & e^{i\theta}\end{bmatrix}.\end{split}\]Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
-
inst:
Literal
['Phase'
]
- property matrix
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'ser_json_inf_nan': 'constants', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
theta:
Annotated
[float
]
-
inst:
- class Rx(**data)
Bases:
Gate1Q
The \(R_{x}(\theta) = e^{-i\theta X/2}\) gate for some rotation angle \(\theta\).
Matrix representation:
\[\begin{split}R_{x}(\theta) = \begin{bmatrix} \cos(\theta/2) & -i\sin(\theta/2) \\ -i\sin(\theta/2) & \cos(\theta/2) \end{bmatrix}.\end{split}\]Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
-
inst:
Literal
['Rx'
]
- property matrix
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'ser_json_inf_nan': 'constants', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
theta:
Annotated
[float
]
-
inst:
- class Ry(**data)
Bases:
Gate1Q
The \(R_{y}(\theta) = e^{-i\theta Y/2}\) gate for some rotation angle \(\theta\).
Matrix representation:
\[\begin{split}R_{y}(\theta) = \begin{bmatrix} \cos(\theta/2) & -\sin(\theta/2) \\ \sin(\theta/2) & \cos(\theta/2) \end{bmatrix}.\end{split}\]Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
-
inst:
Literal
['Ry'
]
- property matrix
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'ser_json_inf_nan': 'constants', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
theta:
Annotated
[float
]
-
inst:
- class Rz(**data)
Bases:
Gate1Q
The \(R_{z}(\theta) = e^{-i\theta Z/2}\) gate for some rotation angle \(\theta\).
Matrix representation:
\[\begin{split}R_{z}(\theta) = \begin{bmatrix} e^{-i\theta/2} & 0 \\ 0 & e^{i\theta/2} \end{bmatrix}.\end{split}\]Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
-
inst:
Literal
['Rz'
]
- property matrix
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'ser_json_inf_nan': 'constants', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
theta:
Annotated
[float
]
-
inst:
- class S(**data)
Bases:
Gate1Q
Implements the \(S\) gate.
This gate is identical to the \(R_{z}(\pi/2)\) gate up to global phase. Matrix representation:
\[\begin{split}S = \begin{bmatrix} 1 & 0 \\ 0 & i \end{bmatrix}.\end{split}\]Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
-
inst:
Literal
['S'
]
- property matrix
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'ser_json_inf_nan': 'constants', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
inst:
- class Sdg(**data)
Bases:
Gate1Q
Implements the adjoint of the \(S\) gate, \(S^{\dagger}\).
This gate is identical to the \(R_{z}(-\pi/2)\) gate up to global phase. Matrix representation:
\[\begin{split}S^{\dagger} = \begin{bmatrix} 1 & 0 \\ 0 & -i \end{bmatrix}.\end{split}\]Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
-
inst:
Literal
['Sdg'
]
- property matrix
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'ser_json_inf_nan': 'constants', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
inst:
- class T(**data)
Bases:
Gate1Q
Implements the \(T\) gate.
This gate is identical to the \(R_{z}(\pi/4)\) gate up to global phase. Matrix representation:
\[\begin{split}T = \begin{bmatrix} 1 & 0 \\ 0 & (1 + i)/\sqrt{2} \end{bmatrix}.\end{split}\]Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
-
inst:
Literal
['T'
]
- property matrix
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'ser_json_inf_nan': 'constants', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
inst:
- class Tdg(**data)
Bases:
Gate1Q
Implements the adjoint of the \(T\) gate, \(T^{\dagger}\).
This gate is identical to the \(R_{z}(-\pi/4)\) gate up to global phase. Matrix representation:
\[\begin{split}T^{\dagger} = \begin{bmatrix} 1 & 0 \\ 0 & (1 - i)/\sqrt{2} \end{bmatrix}.\end{split}\]Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
-
inst:
Literal
['Tdg'
]
- property matrix
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'ser_json_inf_nan': 'constants', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
inst:
- class U(**data)
Bases:
Gate1Q
Implements the \(U(\theta, \phi, \lambda)\) rotation gate defined by three rotation angles.
The gate can be expressed as
\[U(\theta, \phi, \lambda) = e^{\frac{1}{2}i\pi(\lambda+\phi)}R_{z}(\phi)R_{y}(\theta)R_{z}(\lambda)\]Matrix representation:
\[\begin{split}U(\theta, \phi, \lambda) = \begin{bmatrix} \cos(\theta/2) & -e^{i\lambda} \sin(\theta/2) \\ e^{i\phi} \sin(\theta/2) & e^{i(\phi+\lambda)} \cos(\theta/2) \end{bmatrix}.\end{split}\]- Parameters:
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- classmethod from_matrix(qubit, mat)
Returns a \(U(\theta, \phi, \lambda)\) gate directly from a 1Q matrix.
Determines the angles using simple algebra.
-
inst:
Literal
['U'
]
-
lambd:
Annotated
[float
]
- property matrix
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'ser_json_inf_nan': 'constants', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
phi:
Annotated
[float
]
-
theta:
Annotated
[float
]
- class X(**data)
Bases:
Gate1Q
Implements the Pauli-X gate.
Matrix representation:
\[\begin{split}X = \begin{bmatrix}0 & 1 \\ 1 & 0 \end{bmatrix}.\end{split}\]- Parameters:
qubit¶ – Target qubit index.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
-
inst:
Literal
['X'
]
- property matrix
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'ser_json_inf_nan': 'constants', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class Y(**data)
Bases:
Gate1Q
Implements the Pauli-Y gate.
Matrix representation:
\[\begin{split}Y = \begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix}.\end{split}\]- Parameters:
qubit¶ – Target qubit index.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
-
inst:
Literal
['Y'
]
- property matrix
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'ser_json_inf_nan': 'constants', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class Z(**data)
Bases:
Gate1Q
Implements the Pauli-Z gate.
Matrix representation:
\[\begin{split}X = \begin{bmatrix}0 & 1 \\ 1 & 0 \end{bmatrix}.\end{split}\]- Parameters:
qubit¶ – Target qubit index.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
-
inst:
Literal
['Z'
]
- property matrix
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'ser_json_inf_nan': 'constants', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].