pub enum QuantumGate {
PauliX,
PauliY,
PauliZ,
RotationX(Param),
RotationY(Param),
RotationZ(Param),
Phase(Param),
Hadamard,
}Expand description
The fundamental set of single-qubit quantum gates supported by the compiler.
Each variant corresponds to a standard gate from the universal gate set.
Rotation gates carry a Param that encodes the rotation angle in radians.
Variants§
PauliX
The Pauli-X (bit-flip) gate.
PauliY
The Pauli-Y gate.
PauliZ
The Pauli-Z (phase-flip) gate.
RotationX(Param)
Rotation about the X-axis by angle θ: Rx(θ) = exp(-i θ/2 · X).
RotationY(Param)
Rotation about the Y-axis by angle θ: Ry(θ) = exp(-i θ/2 · Y).
RotationZ(Param)
Rotation about the Z-axis by angle θ: Rz(θ) = exp(-i θ/2 · Z).
Phase(Param)
Phase gate: P(λ) = diag(1, e^{iλ}).
Hadamard
The Hadamard gate.
Implementations§
Source§impl QuantumGate
impl QuantumGate
Sourcepub fn is_permutation(&self) -> bool
pub fn is_permutation(&self) -> bool
Returns true if the gate acts as a permutation of computational-basis
states (including X-rotations by ±π).
Sourcepub fn param_index(&self) -> Option<(usize, f64)>
pub fn param_index(&self) -> Option<(usize, f64)>
Returns the parameter index and multiplier if this gate holds a
Param::Ref (i.e., a symbolic variational parameter).
Returns Some((index, multiplier)) for RotationX, RotationY,
RotationZ, and Phase variants whose parameter is a Param::Ref.
Returns None for all other gates or when the parameter is a
concrete Param::Value.
Used by the parameter-shift rule to identify which gate instructions correspond to a given parameter index.
Sourcepub const fn is_diagonal(&self) -> bool
pub const fn is_diagonal(&self) -> bool
Returns true if the gate is diagonal in the computational basis.
Sourcepub fn inverse(&self) -> Self
pub fn inverse(&self) -> Self
Returns the adjoint (Hermitian conjugate / inverse) of this gate.
Sourcepub fn propriety(&self) -> GatePropriety
pub fn propriety(&self) -> GatePropriety
Classifies the gate according to its action on the computational basis.
Sourcepub fn merge(&self, other: &Self) -> Option<Self>
pub fn merge(&self, other: &Self) -> Option<Self>
Attempts to merge two consecutive same-type rotation gates into one.
Returns Some(merged) when both gates are the same rotation axis and
their parameters can be added (see Param::add), or None otherwise.
Sourcepub fn is_near_zero(&self, epsilon: f64) -> bool
pub fn is_near_zero(&self, epsilon: f64) -> bool
Returns true if the gate’s rotation angle is within epsilon of zero,
making it effectively the identity.
Only parametric gates (Rotation* and Phase) can be near zero;
non-parametric gates always return false.
Sourcepub fn set_parameter(&self, parameters: &[f64]) -> Self
pub fn set_parameter(&self, parameters: &[f64]) -> Self
Binds all symbolic parameters in this gate to their concrete values.
For non-parametric gates (PauliX, PauliY, PauliZ, Hadamard)
this is a no-op and returns a copy of self. For parametric gates the
Param is resolved via Param::set_parameter.
Trait Implementations§
Source§impl Clone for QuantumGate
impl Clone for QuantumGate
Source§fn clone(&self) -> QuantumGate
fn clone(&self) -> QuantumGate
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for QuantumGate
Source§impl Debug for QuantumGate
impl Debug for QuantumGate
Source§impl<'de> Deserialize<'de> for QuantumGate
impl<'de> Deserialize<'de> for QuantumGate
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for QuantumGate
impl PartialEq for QuantumGate
Source§impl Serialize for QuantumGate
impl Serialize for QuantumGate
impl StructuralPartialEq for QuantumGate
Auto Trait Implementations§
impl Freeze for QuantumGate
impl RefUnwindSafe for QuantumGate
impl Send for QuantumGate
impl Sync for QuantumGate
impl Unpin for QuantumGate
impl UnsafeUnpin for QuantumGate
impl UnwindSafe for QuantumGate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more