qilisdk.digital.gates
Attributes
Classes
Represents a quantum gate that can be used in quantum circuits. |
|
Represents a quantum gate that can be used in quantum circuits. |
|
Represents a quantum gate that can be used in quantum circuits. |
|
Represents a quantum gate that can be used in quantum circuits. |
|
Represents the adjoint (conjugate transpose) of a unitary gate. |
|
Represents the exponential of a unitary gate. |
|
Measurement operation on a qubit. The measurement is performed in the computational basis and the |
|
The Identity gate. |
|
The Pauli-X gate. |
|
The Pauli-Y gate. |
|
The Pauli-Z gate. |
|
The Hadamard gate. |
|
Represents the S gate, which induces a pi/2 phase. |
|
Represents the T gate, which induces a pi/4 phase. |
|
Represents a theta angle rotation around the X-axis (polar) in the Bloch sphere. |
|
Represents a theta angle rotation around the Y-axis (polar) in the Bloch sphere. |
|
Represents a phi angle rotation around the Z-axis (azimuthal) in the Bloch sphere. |
|
Represents the U1 gate defined by an azimuthal angle phi. |
|
Represents the U2 gate defined by the angles phi and gamma. |
|
Represents the U3 gate defined by the angles theta, phi and gamma. |
|
Represents the CNOT gate. |
|
Represents the CZ gate. |
|
The SWAP gate. |
Module Contents
- TBasicGate[fuente]
- class Gate[fuente]
Bases:
qilisdk.core.parameterizable.Parameterizable,abc.ABCRepresents a quantum gate that can be used in quantum circuits.
- PARAMETER_NAMES: ClassVar[list[str]] = [][fuente]
- property name: str[fuente]
- Abstractmethod:
Retrieve the name of the gate.
- Devuelve:
The name of the gate.
- Tipo del valor devuelto:
str
- property matrix: numpy.ndarray[fuente]
- Abstractmethod:
Retrieve the matrix of the gate.
- Muestra:
GateHasNoMatrixError – If gate has no matrix.
- Devuelve:
The matrix of the gate.
- Tipo del valor devuelto:
np.ndarray
- property control_qubits: tuple[int, Ellipsis][fuente]
Retrieve the indices of the control qubits.
- Devuelve:
A tuple containing the indices of the control qubits.
- Tipo del valor devuelto:
tuple[int, …]
- property target_qubits: tuple[int, Ellipsis][fuente]
Retrieve the indices of the target qubits.
- Devuelve:
A tuple containing the indices of the target qubits.
- Tipo del valor devuelto:
tuple[int, …]
- property qubits: tuple[int, Ellipsis][fuente]
Retrieve all qubits associated with the gate, including both control and target qubits.
- Devuelve:
A tuple of all qubit indices on which the gate operates.
- Tipo del valor devuelto:
tuple[int, …]
- property nqubits: int[fuente]
Retrieve the number of qubits the gate acts upon.
- Devuelve:
The number of qubits for this gate.
- Tipo del valor devuelto:
int
- property nparameters: int[fuente]
Retrieve the number of parameters for the gate.
- Devuelve:
The count of parameters needed by the gate.
- Tipo del valor devuelto:
int
- property is_parameterized: bool[fuente]
Determine whether the gate requires parameters.
- Devuelve:
True if the gate is parameterized; otherwise, False.
- Tipo del valor devuelto:
bool
- property parameters: dict[str, qilisdk.core.variables.Parameter][fuente]
Returns the raw parameter objects stored in the gate.
- Devuelve:
A dictionary mapping each Parameter object to its label.
- Tipo del valor devuelto:
dict[str, Parameter]
- get_parameters() dict[str, float][fuente]
Retrieve a mapping of parameter names to their corresponding values.
- Devuelve:
A dictionary mapping each parameter name to its numeric value.
- Tipo del valor devuelto:
dict[str, float]
- get_parameter_names() list[str][fuente]
Retrieve the symbolic names of the gate’s parameters.
- Devuelve:
A list containing the names of the parameters.
- Tipo del valor devuelto:
list[str]
- get_parameter_values() list[float][fuente]
Retrieve the numerical values assigned to the gate’s parameters.
- Devuelve:
A list containing the parameter values.
- Tipo del valor devuelto:
list[float]
- set_parameters(parameters: dict[str, float]) None[fuente]
Set the parameters for the gate using a dictionary mapping names to values.
- Parámetros:
parameters (
dict[str,float]) – A dictionary where keys are parameter names and values are the new parameter values.- Muestra:
GateNotParameterizedError – If gate is not parameterized.
InvalidParameterNameError – If any provided parameter name is not valid for this gate.
- set_parameter_values(values: list[float]) None[fuente]
Set the numerical values for the gate’s parameters.
- Parámetros:
values (
list[float]) – A list containing new parameter values.- Muestra:
GateNotParameterizedError – If gate is not parameterized.
ParametersNotEqualError – If the number of provided values does not match the expected parameter count.
- get_parameter_bounds() dict[str, tuple[float, float]][fuente]
Return the
(lower, upper)bounds associated with each parameter.
- set_parameter_bounds(ranges: dict[str, tuple[float, float]]) None[fuente]
Update the allowable ranges for the specified parameters.
- Parámetros:
ranges (
dict[str,tuple[float,float]]) – Mapping from parameter label to(lower, upper)bounds.- Muestra:
ValueError – If an unknown parameter label is provided.
- class BasicGate(target_qubits: tuple[int, Ellipsis], parameters: dict[str, qilisdk.core.variables.Parameter] | None = None, parameter_transforms: dict[str, qilisdk.core.variables.Term] | None = None)[fuente]
Bases:
GateRepresents a quantum gate that can be used in quantum circuits.
Build a basic gate.
- Parámetros:
target_qubits (
tuple[int,]) – Qubit indices the gate acts on. Duplicate indices are rejected.parameters (
dict[str,Parameter] | None) – Optional parameter objects keyed by label for parameterized gates.
- Muestra:
ValueError – if duplicate target qubits are found.
ValueError – if any parameter transform is not a parameterized term.
InvalidParameterNameError – if any parameter mentioned in parameter_transforms is not in parameters.
- property matrix: numpy.ndarray[fuente]
Retrieve the matrix of the gate.
- Muestra:
GateHasNoMatrixError – If gate has no matrix.
- Devuelve:
The matrix of the gate.
- Tipo del valor devuelto:
np.ndarray
- property target_qubits: tuple[int, Ellipsis][fuente]
Retrieve the indices of the target qubits.
- Devuelve:
A tuple containing the indices of the target qubits.
- Tipo del valor devuelto:
tuple[int, …]
- property parameters: dict[str, qilisdk.core.variables.Parameter][fuente]
Returns the raw parameter objects stored in the gate.
- Devuelve:
A dictionary mapping each Parameter object to its label.
- Tipo del valor devuelto:
dict[str, Parameter]
- get_parameters() dict[str, float][fuente]
Retrieve a mapping of parameter names to their corresponding values.
- Devuelve:
A dictionary mapping each parameter name to its numeric value.
- Tipo del valor devuelto:
dict[str, float]
- set_parameters(parameters: dict[str, float]) None[fuente]
Set the parameters for the gate using a dictionary mapping names to values.
- Parámetros:
parameters (
dict[str,float]) – A dictionary where keys are parameter names and values are the new parameter values.- Muestra:
GateNotParameterizedError – If gate is not parameterized.
InvalidParameterNameError – If any provided parameter name is not valid for this gate.
- set_parameter_values(values: list[float]) None[fuente]
Set the numerical values for the gate’s parameters.
- Parámetros:
values (
list[float]) – A list containing new parameter values.- Muestra:
GateNotParameterizedError – If gate is not parameterized.
ParametersNotEqualError – If the number of provided values does not match the expected parameter count.
- get_parameter_bounds() dict[str, tuple[float, float]][fuente]
Return the
(lower, upper)bounds associated with each parameter.
- set_parameter_bounds(ranges: dict[str, tuple[float, float]]) None[fuente]
Update the allowable ranges for the specified parameters.
- Parámetros:
ranges (
dict[str,tuple[float,float]]) – Mapping from parameter label to(lower, upper)bounds.- Muestra:
ValueError – If an unknown parameter label is provided.
- controlled(*control_qubits: int) Controlled[Self][fuente]
Creates a controlled version of this unitary gate.
This method returns a new instance of a Controlled gate where the provided qubits serve as the control qubits and the current unitary gate is used as the target. The resulting gate operates on both the control and target qubits.
- Parámetros:
*control_qubits (
int) – One or more integer indices specifying the control qubits.- Devuelve:
A new Controlled gate instance that wraps this unitary gate with the specified control qubits.
- Tipo del valor devuelto:
- adjoint() Adjoint[Self][fuente]
Returns the adjoint (conjugate transpose) of this unitary gate.
This method constructs and returns a new gate whose matrix is the conjugate transpose of the current gate’s matrix. The adjoint (or Hermitian conjugate) is commonly used to reverse the effect of a unitary operation.
- Devuelve:
A new Adjoint gate instance representing the adjoint of this gate.
- Tipo del valor devuelto:
- exponential() Exponential[Self][fuente]
Returns the exponential of this unitary gate.
This method computes the matrix exponential of the current gate’s matrix, resulting in a new gate. The matrix exponential is useful for representing continuous time evolution in quantum systems and appears in various quantum mechanics and quantum computing applications.
- Devuelve:
A new Exponential gate instance whose matrix is the matrix exponential of the current gate’s matrix.
- Tipo del valor devuelto:
- class Modified(basic_gate: TBasicGate)[fuente]
Bases:
Gate,Generic[TBasicGate]Represents a quantum gate that can be used in quantum circuits.
- property basic_gate: TBasicGate[fuente]
- property matrix: numpy.ndarray[fuente]
Retrieve the matrix of the gate.
- Muestra:
GateHasNoMatrixError – If gate has no matrix.
- Devuelve:
The matrix of the gate.
- Tipo del valor devuelto:
np.ndarray
- property target_qubits: tuple[int, Ellipsis][fuente]
Retrieve the indices of the target qubits.
- Devuelve:
A tuple containing the indices of the target qubits.
- Tipo del valor devuelto:
tuple[int, …]
- property nparameters: int[fuente]
Retrieve the number of parameters for the gate.
- Devuelve:
The count of parameters needed by the gate.
- Tipo del valor devuelto:
int
- property is_parameterized: bool[fuente]
Determine whether the gate requires parameters.
- Devuelve:
True if the gate is parameterized; otherwise, False.
- Tipo del valor devuelto:
bool
- property parameters: dict[str, qilisdk.core.variables.Parameter][fuente]
Returns the raw parameter objects stored in the gate.
- Devuelve:
A dictionary mapping each Parameter object to its label.
- Tipo del valor devuelto:
dict[str, Parameter]
- get_parameters() dict[str, float][fuente]
Retrieve a mapping of parameter names to their corresponding values.
- Devuelve:
A dictionary mapping each parameter name to its numeric value.
- Tipo del valor devuelto:
dict[str, float]
- get_parameter_names() list[str][fuente]
Retrieve the symbolic names of the gate’s parameters.
- Devuelve:
A list containing the names of the parameters.
- Tipo del valor devuelto:
list[str]
- get_parameter_values() list[float][fuente]
Retrieve the numerical values assigned to the gate’s parameters.
- Devuelve:
A list containing the parameter values.
- Tipo del valor devuelto:
list[float]
- set_parameters(parameters: dict[str, float]) None[fuente]
Set the parameters for the gate using a dictionary mapping names to values.
- Parámetros:
parameters (
dict[str,float]) – A dictionary where keys are parameter names and values are the new parameter values.- Muestra:
GateNotParameterizedError – If gate is not parameterized.
InvalidParameterNameError – If any provided parameter name is not valid for this gate.
- set_parameter_values(values: list[float]) None[fuente]
Set the numerical values for the gate’s parameters.
- Parámetros:
values (
list[float]) – A list containing new parameter values.- Muestra:
GateNotParameterizedError – If gate is not parameterized.
ParametersNotEqualError – If the number of provided values does not match the expected parameter count.
- get_parameter_bounds() dict[str, tuple[float, float]][fuente]
Return the
(lower, upper)bounds associated with each parameter.
- set_parameter_bounds(ranges: dict[str, tuple[float, float]]) None[fuente]
Update the allowable ranges for the specified parameters.
- Parámetros:
ranges (
dict[str,tuple[float,float]]) – Mapping from parameter label to(lower, upper)bounds.- Muestra:
ValueError – If an unknown parameter label is provided.
- is_modified_from(gate_type: type[TBasicGate]) bool[fuente]
- class Controlled(*control_qubits: int, basic_gate: TBasicGate)[fuente]
Bases:
Modified[TBasicGate]Represents a quantum gate that can be used in quantum circuits.
- property control_qubits: tuple[int, Ellipsis][fuente]
Retrieve the indices of the control qubits.
- Devuelve:
A tuple containing the indices of the control qubits.
- Tipo del valor devuelto:
tuple[int, …]
- property name: str[fuente]
Retrieve the name of the gate.
- Devuelve:
The name of the gate.
- Tipo del valor devuelto:
str
- class Adjoint(basic_gate: TBasicGate)[fuente]
Bases:
Modified[TBasicGate]Represents the adjoint (conjugate transpose) of a unitary gate.
- property name: str[fuente]
Get the name of the adjoint gate.
The name is constructed by appending an adjoint symbol (†) to the name of the underlying gate. For example, if the underlying gate’s name is «X», this property returns «X†».
- Devuelve:
The name of the adjoint gate.
- Tipo del valor devuelto:
str
- class Exponential(basic_gate: TBasicGate)[fuente]
Bases:
Modified[TBasicGate]Represents the exponential of a unitary gate. The matrix of this gate is computed as the matrix exponential (e^(gate.matrix)) of the underlying gate’s matrix.
- property name: str[fuente]
Get the name of the exponential gate.
The name is constructed by prepending the underlying gate’s name within «e^». For example, if the underlying gate’s name is «X», the exponential gate’s name is «e^X».
- Devuelve:
The generated name of the exponential gate.
- Tipo del valor devuelto:
str
- class M(*qubits: int)[fuente]
Bases:
GateMeasurement operation on a qubit. The measurement is performed in the computational basis and the result is stored in a classical bit with the same label as the measured qubit.
Initialize a measurement operation.
- Parámetros:
qubit (
int) – The qubit index to be measured.
- property name: str[fuente]
Retrieve the name of the gate.
- Devuelve:
The name of the gate.
- Tipo del valor devuelto:
str
- property matrix: numpy.ndarray[fuente]
Retrieve the matrix of the gate.
- Muestra:
GateHasNoMatrixError – If gate has no matrix.
- Devuelve:
The matrix of the gate.
- Tipo del valor devuelto:
np.ndarray
- property target_qubits: tuple[int, Ellipsis][fuente]
Retrieve the indices of the target qubits.
- Devuelve:
A tuple containing the indices of the target qubits.
- Tipo del valor devuelto:
tuple[int, …]
- class I(qubit: int)[fuente]
Bases:
BasicGateThe Identity gate.
The associated matrix is:
[[1, 0], [0, 1]]Initialize a Pauli-X gate.
- Parámetros:
qubit (
int) – The target qubit index for the X gate.
- property name: str[fuente]
Retrieve the name of the gate.
- Devuelve:
The name of the gate.
- Tipo del valor devuelto:
str
- class X(qubit: int)[fuente]
Bases:
BasicGateThe Pauli-X gate.
The associated matrix is:
[[0, 1], [1, 0]]This is a pi radians rotation around the X-axis in the Bloch sphere.
Initialize a Pauli-X gate.
- Parámetros:
qubit (
int) – The target qubit index for the X gate.
- property name: str[fuente]
Retrieve the name of the gate.
- Devuelve:
The name of the gate.
- Tipo del valor devuelto:
str
- class Y(qubit: int)[fuente]
Bases:
BasicGateThe Pauli-Y gate.
The associated matrix is:
[[ 0, -i ], [ i, 0 ]]This is a pi radians rotation around the Y-axis in the Bloch sphere.
Initialize a Pauli-Y gate.
- Parámetros:
qubit (
int) – The target qubit index for the Y gate.
- property name: str[fuente]
Retrieve the name of the gate.
- Devuelve:
The name of the gate.
- Tipo del valor devuelto:
str
- class Z(qubit: int)[fuente]
Bases:
BasicGateThe Pauli-Z gate.
The associated matrix is:
[[1, 0], [0, -1]]This is a pi radians rotation around the Z-axis in the Bloch sphere.
Initialize a Pauli-Z gate.
- Parámetros:
qubit (
int) – The target qubit index for the Z gate.
- property name: str[fuente]
Retrieve the name of the gate.
- Devuelve:
The name of the gate.
- Tipo del valor devuelto:
str
- class H(qubit: int)[fuente]
Bases:
BasicGateThe Hadamard gate.
The associated matrix is:
[[1/sqrt(2), 1/sqrt(2)], [1/sqrt(2), -1/sqrt(2)]]This is a pi radians rotation around the (X+Z)-axis in the Bloch sphere.
Initialize a Hadamard gate.
- Parámetros:
qubit (
int) – The target qubit index for the Hadamard gate.
- property name: str[fuente]
Retrieve the name of the gate.
- Devuelve:
The name of the gate.
- Tipo del valor devuelto:
str
- class S(qubit: int)[fuente]
Bases:
BasicGateRepresents the S gate, which induces a pi/2 phase.
The associated matrix is:
[[1, 0], [0, i]]This gate is also known as the square root of Z gate:
S**2=Z, or equivalently it is a pi/2 radians rotation around the Z-axis in the Bloch sphere.Initialize an S gate.
- Parámetros:
qubit (
int) – The target qubit index for the S gate.
- property name: str[fuente]
Retrieve the name of the gate.
- Devuelve:
The name of the gate.
- Tipo del valor devuelto:
str
- class T(qubit: int)[fuente]
Bases:
BasicGateRepresents the T gate, which induces a pi/4 phase.
The associated matrix is:
[[1, 0], [0, exp(i*pi/4)]]This gate is also known as the fourth-root of Z gate:
T**4=Z, or equivalently it is a pi/4 radians rotation around the Z-axis in the Bloch sphere.Initialize a T gate.
- Parámetros:
qubit (
int) – The target qubit index for the T gate.
- property name: str[fuente]
Retrieve the name of the gate.
- Devuelve:
The name of the gate.
- Tipo del valor devuelto:
str
- class RX(qubit: int, *, theta: float | qilisdk.core.variables.Parameter | qilisdk.core.variables.Term)[fuente]
Bases:
BasicGateRepresents a theta angle rotation around the X-axis (polar) in the Bloch sphere.
The associated matrix is:
[[cos(theta/2), -i*sin(theta/2)], [-i*sin(theta/2), cos(theta/2)]]- This is an exponential of the Pauli-X operator:
RX(theta) = exp(-i*theta*X/2)
Initialize an RX gate.
- Parámetros:
qubit (
int) – The target qubit index for the rotation.theta (
float | Parameter | Term) – The rotation angle (polar) in radians.
- PARAMETER_NAMES: ClassVar[list[str]] = ['theta'][fuente]
- property name: str[fuente]
Retrieve the name of the gate.
- Devuelve:
The name of the gate.
- Tipo del valor devuelto:
str
- property theta: float[fuente]
- class RY(qubit: int, *, theta: float | qilisdk.core.variables.Parameter | qilisdk.core.variables.Term)[fuente]
Bases:
BasicGateRepresents a theta angle rotation around the Y-axis (polar) in the Bloch sphere.
The associated matrix is:
[[cos(theta/2), -sin(theta/2)], [sin(theta/2), cos(theta/2)]]- This is an exponential of the Pauli-Y operator:
RY(theta) = exp(-i*theta*Y/2)
Initialize an RY gate.
- Parámetros:
qubit (
int) – The target qubit index for the rotation.theta (
float | Parameter | Term) – The rotation angle (polar) in radians.
- PARAMETER_NAMES: ClassVar[list[str]] = ['theta'][fuente]
- property name: str[fuente]
Retrieve the name of the gate.
- Devuelve:
The name of the gate.
- Tipo del valor devuelto:
str
- property theta: float[fuente]
- class RZ(qubit: int, *, phi: float | qilisdk.core.variables.Parameter | qilisdk.core.variables.Term)[fuente]
Bases:
BasicGateRepresents a phi angle rotation around the Z-axis (azimuthal) in the Bloch sphere.
The associated matrix is:
[[exp(-i*phi/2), 0], [0, exp(i*phi/2)]]- This is an exponential of the Pauli-Z operator:
RZ(phi) = exp(-i*phi*Z/2)- Which is equivalent to the U1 gate plus a global phase:
RZ(phi) = exp(-i*phi/2)U1(phi)- Other unitaries you can get from this one are:
RZ(phi=pi) = exp(-i*pi/2) Z = -i ZRZ(phi=pi/2) = exp(-i*pi/4) SRZ(phi=pi/4) = exp(-i*pi/8) T
Initialize an RZ gate.
- Parámetros:
qubit (
int) – The target qubit index for the rotation.phi (
float | Parameter | Term) – The rotation angle (azimuthal) in radians.
- PARAMETER_NAMES: ClassVar[list[str]] = ['phi'][fuente]
- property name: str[fuente]
Retrieve the name of the gate.
- Devuelve:
The name of the gate.
- Tipo del valor devuelto:
str
- property phi: float[fuente]
- class U1(qubit: int, *, phi: float | qilisdk.core.variables.Parameter | qilisdk.core.variables.Term)[fuente]
Bases:
BasicGateRepresents the U1 gate defined by an azimuthal angle phi.
The associated matrix is:
[[1, 0], [0, exp(i*phi)]]- Which is equivalent to the RZ gate plus a global phase:
U1(phi) = exp(i*phi/2)RZ(phi)- Other unitaries you can get from this one are:
U1(phi=np.pi) = ZU1(phi=np.pi/2) = SU1(phi=np.pi/4) = T
Initialize a U1 gate.
- Parámetros:
qubit (
int) – The target qubit index for the U1 gate.phi (
float | Parameter | Term) – The phase to add, or equivalently the rotation angle (azimuthal) in radians.
- PARAMETER_NAMES: ClassVar[list[str]] = ['phi'][fuente]
- property name: str[fuente]
Retrieve the name of the gate.
- Devuelve:
The name of the gate.
- Tipo del valor devuelto:
str
- property phi: float[fuente]
- class U2(qubit: int, *, phi: float | qilisdk.core.variables.Parameter | qilisdk.core.variables.Term, gamma: float | qilisdk.core.variables.Parameter | qilisdk.core.variables.Term)[fuente]
Bases:
BasicGateRepresents the U2 gate defined by the angles phi and gamma.
The associated matrix is:
1/sqrt(2)*[[1, -exp(i*gamma)], [exp(i*phi), exp(i*(phi+gamma))]]- Which is equivalent to two azimuthal rotations of phi and gamma, with a pi/2 polar rotation in between:
U2(phi, gamma) = exp(i*(phi+gamma)/2) RZ(phi) RY(pi/2) RZ(gamma)- This is the same matrix of qiskit and pennylane, differing from qibo implementation on a global phase:
U2(phi, gamma) = U2_qiskit/pennylane(phi, gamma) = exp(i*(phi+gamma)/2) U2_qibo(phi, gamma)- Other unitaries you can get from this one are:
U2(phi=0, gamma=pi) = HU2(phi=0, gamma=0) = RY(theta=pi/2)U2(phi=-pi/2, gamma=pi/2) = RX(theta=pi/2)
Initialize a U2 gate.
- Parámetros:
qubit (
int) – The target qubit index for the U2 gate.phi (
float | Parameter | Term) – The first phase parameter, or equivalently the first rotation angle (azimuthal) in radians.gamma (
float | Parameter | Term) – The second phase parameter, or equivalently the second rotation angle (azimuthal) in radians.
- PARAMETER_NAMES: ClassVar[list[str]] = ['phi', 'gamma'][fuente]
- property name: str[fuente]
Retrieve the name of the gate.
- Devuelve:
The name of the gate.
- Tipo del valor devuelto:
str
- property phi: float[fuente]
- property gamma: float[fuente]
- class U3(qubit: int, *, theta: float | qilisdk.core.variables.Parameter | qilisdk.core.variables.Term, phi: float | qilisdk.core.variables.Parameter | qilisdk.core.variables.Term, gamma: float | qilisdk.core.variables.Parameter | qilisdk.core.variables.Term)[fuente]
Bases:
BasicGateRepresents the U3 gate defined by the angles theta, phi and gamma.
The associated matrix is:
[[cos(theta/2), -exp(i*gamma/2*sin(theta/2))], [exp(i*phi/2)*sin(theta/2), exp(i*(phi+gamma))*cos(theta/2)]]- Which is equivalent to two azimuthal rotations of phi and gamma, with a “theta” polar rotation in between:
U3(theta, phi, gamma) = exp(i*(phi+gamma)/2) RZ(phi) RY(theta) RZ(gamma)- This is the same matrix of qiskit and pennylane, differing from QASM and qibo implementation on a global phase:
U3(theta, phi, gamma) = U3_qiskit/pennylane(theta, phi, gamma) = exp(-i*(phi+gamma)/2) U3_QASM/qibo(theta, phi, gamma)- Other unitaries you can get from this one are:
U3(theta=pi/2, phi, gamma) = U2(phi, gamma)U3(theta=0, phi=0, gamma) = U1(gamma)andU3(theta=0, phi, gamma=0) = U1(phi)U3(theta, phi=0, gamma=0) = RY(theta)U3(theta, phi=-pi/2, gamma=pi/2) = RX(theta)
Initialize a U3 gate.
- Parámetros:
qubit (
int) – The target qubit index for the U3 gate.theta (
float | Parameter | Term) – The rotation angle (polar), in between both phase rotations (azimuthal).phi (
float | Parameter | Term) – The first phase parameter, or equivalently the first rotation angle (azimuthal) in radians.gamma (
float | Parameter | Term) – The second phase parameter, or equivalently the second rotation angle (azimuthal) in radians.
- PARAMETER_NAMES: ClassVar[list[str]] = ['theta', 'phi', 'gamma'][fuente]
- property name: str[fuente]
Retrieve the name of the gate.
- Devuelve:
The name of the gate.
- Tipo del valor devuelto:
str
- property theta: float[fuente]
- property phi: float[fuente]
- property gamma: float[fuente]
- class CNOT(control: int, target: int)[fuente]
Bases:
Controlled[X]Represents the CNOT gate.
The associated matrix is:
[[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]]- Which is equivalent to the CZ gate surrounded by two H’s gates on the target qubit:
CNOT(control, target) = H(target) CZ(control, target) H(target)
- property name: str[fuente]
Retrieve the name of the gate.
- Devuelve:
The name of the gate.
- Tipo del valor devuelto:
str
- class CZ(control: int, target: int)[fuente]
Bases:
Controlled[Z]Represents the CZ gate.
The associated matrix is:
[[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, -1]]- This gate is totally symmetric respect control and target, meaning that both are control and target in reality:
CZ(control, target) = CZ(target, control)- It is also equivalent to the CNOT gate surrounded by two H’s gates on the target qubit:
CZ(control, target) = H(target) CNOT(control, target) H(target)