Skip to main content

QuantumGate

Enum QuantumGate 

Source
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

Source

pub fn is_permutation(&self) -> bool

Returns true if the gate acts as a permutation of computational-basis states (including X-rotations by ±π).

Source

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.

Source

pub const fn is_diagonal(&self) -> bool

Returns true if the gate is diagonal in the computational basis.

Source

pub fn inverse(&self) -> Self

Returns the adjoint (Hermitian conjugate / inverse) of this gate.

Source

pub fn propriety(&self) -> GatePropriety

Classifies the gate according to its action on the computational basis.

Source

pub const fn s() -> Self

Constructs an S gate (Phase(π/2)).

Source

pub fn sd() -> Self

Constructs an S† gate (Phase(-π/2)).

Source

pub const fn t() -> Self

Constructs a T gate (Phase(π/4)).

Source

pub fn td() -> Self

Constructs a T† gate (Phase(-π/4)).

Source

pub const fn sqrt_t() -> Self

Constructs a √T gate (Phase(π/8)).

Source

pub fn sqrt_td() -> Self

Constructs a √T† gate (Phase(-π/8)).

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> QuantumGate

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for QuantumGate

Source§

impl Debug for QuantumGate

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for QuantumGate

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for QuantumGate

Source§

fn eq(&self, other: &QuantumGate) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for QuantumGate

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for QuantumGate

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.