Skip to main content

GateType

Enum GateType 

Source
pub enum GateType {
Show 42 variants RX, RY, RZ, XCX, XCY, XCZ, YCX, YCY, YCZ, CX, CY, CZ, H, H_XY, H_YZ, H_NXY, H_NXZ, H_NYZ, I, X, Y, Z, SQRT_X, SQRT_X_DAG, SQRT_Y, SQRT_Y_DAG, S, S_DAG, C_XYZ, C_ZYX, C_NXYZ, C_XNYZ, C_XYNZ, C_NZYX, C_ZNYX, C_ZYNX, T_YZ, T_YZ_DAG, T_XZ, T_XZ_DAG, T, T_DAG,
}
Expand description

A quantum gate, named after its Stim mnemonic.

Variant names follow Stim’s gate set. strum aliases map the common synonyms (e.g. CNOT and ZCX both parse to GateType::CX, and R renders/parses GateType::RZ).

Variants§

§

RX

X-basis reset.

§

RY

Y-basis reset.

§

RZ

Z-basis reset (R in Stim text).

§

XCX

X-controlled X.

§

XCY

X-controlled Y.

§

XCZ

X-controlled Z.

§

YCX

Y-controlled X.

§

YCY

Y-controlled Y.

§

YCZ

Y-controlled Z.

§

CX

Z-controlled X.

§

CY

Z-controlled Y.

§

CZ

Z-controlled Z.

§

H

Exchanges X and Z axes.

§

H_XY

Exchanges X and Y axes.

§

H_YZ

Exchanges Y and Z axes.

§

H_NXY

Negated X/Y-axis exchange.

§

H_NXZ

Negated X/Z-axis exchange.

§

H_NYZ

Negated Y/Z-axis exchange.

§

I

Identity.

§

X

Pauli X.

§

Y

Pauli Y.

§

Z

Pauli Z.

§

SQRT_X

Positive square root of X.

§

SQRT_X_DAG

Inverse square root of X.

§

SQRT_Y

Positive square root of Y.

§

SQRT_Y_DAG

Inverse square root of Y.

§

S

Positive square root of Z.

§

S_DAG

Inverse square root of Z.

§

C_XYZ

Cycles X to Y to Z.

§

C_ZYX

Cycles Z to Y to X.

§

C_NXYZ

Negated X/Y/Z cycle.

§

C_XNYZ

X/negated-Y/Z cycle.

§

C_XYNZ

X/Y/negated-Z cycle.

§

C_NZYX

Negated-X/Z/Y cycle.

§

C_ZNYX

Z/negated-Y/X cycle.

§

C_ZYNX

Z/Y/negated-X cycle.

§

T_YZ

Positive pi/4 rotation about X.

§

T_YZ_DAG

Negative pi/4 rotation about X.

§

T_XZ

Positive pi/4 rotation about Y.

§

T_XZ_DAG

Negative pi/4 rotation about Y.

§

T

Positive pi/4 rotation about Z.

§

T_DAG

Negative pi/4 rotation about Z.

Implementations§

Source§

impl GateType

Source

pub fn iter() -> impl Iterator<Item = Self>

Iterates over every gate. Lets a caller sweep the whole gate set — filtered by Self::is_reset, Self::is_non_clifford, and Self::is_two_qubit_gate — without depending on strum itself.

Source

pub const fn is_reset(&self) -> bool

Returns true for the reset gates (RX, RY, RZ).

Source

pub const fn is_non_clifford(&self) -> bool

Returns true for the non-Clifford T-family gates.

Source

pub const fn is_two_qubit_gate(&self) -> bool

Returns true for the two-qubit unitary (controlled) gates.

Source

pub const fn clifford_proxy(&self) -> GateType

Maps a non-Clifford gate to the Clifford that shares its axis and sign, so stabilizer-flow analysis can treat a T gate as its S proxy. Clifford gates map to themselves.

Source

pub const fn two_qubit_bases(&self) -> Option<(PauliBasis, PauliBasis)>

For two-qubit gates in the ACB naming convention, returns the (control, target) Pauli bases — CX (= ZCX) is Z-control, X-target. None for non-two-qubit gates.

Trait Implementations§

Source§

impl Clone for GateType

Source§

fn clone(&self) -> GateType

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 GateType

Source§

impl Debug for GateType

Source§

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

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

impl<'de> Deserialize<'de> for GateType

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 Display for GateType

Source§

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

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

impl Eq for GateType

Source§

impl<'_derivative_strum> From<&'_derivative_strum GateType> for &'static str

Source§

fn from(x: &'_derivative_strum GateType) -> &'static str

Converts to this type from the input type.
Source§

impl From<GateType> for &'static str

Source§

fn from(x: GateType) -> &'static str

Converts to this type from the input type.
Source§

impl FromStr for GateType

Source§

type Err = ParseError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<GateType, <Self as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for GateType

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl IntoEnumIterator for GateType

Source§

type Iterator = GateTypeIter

Source§

fn iter() -> GateTypeIter

Source§

impl Ord for GateType

Source§

fn cmp(&self, other: &GateType) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for GateType

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl PartialOrd for GateType

Source§

fn partial_cmp(&self, other: &GateType) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for GateType

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 GateType

Source§

impl TryFrom<&str> for GateType

Source§

type Error = ParseError

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

fn try_from(s: &str) -> Result<GateType, <Self as TryFrom<&str>>::Error>

Performs the conversion.

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
§

impl<T, BorrowedSelf> BitwiseMutViaBorrow<BorrowedSelf> for T
where T: BorrowMut<BorrowedSelf>, BorrowedSelf: BitwiseMut + ?Sized,

§

fn assign_index(&mut self, index: usize, to: bool)

§

fn negate_index(&mut self, index: usize)

§

fn clear_bits(&mut self)

§

fn assign_random( &mut self, bit_count: usize, random_number_generator: &mut impl RngExt, )
where BorrowedSelf: BitLength,

§

impl<Bits, Other, BorrowedSelf, BorrowedOther> BitwisePairMutViaBorrow<Other, BorrowedSelf, BorrowedOther> for Bits
where Bits: BorrowMut<BorrowedSelf> + ?Sized, Other: Borrow<BorrowedOther> + ?Sized, BorrowedSelf: Bitwise + BitwisePairMut<BorrowedOther> + ?Sized, BorrowedOther: Bitwise + ?Sized,

§

fn assign(&mut self, other: &Other)

§

fn bitxor_assign(&mut self, other: &Other)

§

fn bitand_assign(&mut self, other: &Other)

§

fn bitor_assign(&mut self, other: &Other)

§

impl<T, Other, BorrowedSelf, BorrowedOther> BitwisePairViaBorrow<Other, BorrowedSelf, BorrowedOther> for T
where T: Borrow<BorrowedSelf> + ?Sized, Other: Borrow<BorrowedOther> + ?Sized, BorrowedSelf: Bitwise + BitwisePair<BorrowedOther> + ?Sized, BorrowedOther: Bitwise + ?Sized,

§

fn dot(&self, other: &Other) -> bool

§

fn and_weight(&self, other: &Other) -> usize

§

fn or_weight(&self, other: &Other) -> usize

§

fn xor_weight(&self, other: &Other) -> usize

§

impl<T, BorrowedSelf> BitwiseViaBorrow<BorrowedSelf> for T
where T: Borrow<BorrowedSelf>, BorrowedSelf: Bitwise + ?Sized,

§

fn index(&self, index: usize) -> bool

§

fn weight(&self) -> usize

§

fn parity(&self) -> bool

§

fn is_zero(&self) -> bool

§

fn is_unit(&self, index: usize) -> bool

§

fn support<'a>(&'a self) -> impl SortedIterator
where BorrowedSelf: 'a,

§

fn max_support(&self) -> Option<usize>

§

fn min_support(&self) -> Option<usize>

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
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

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

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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<N> NodeTrait for N
where N: Copy + Ord + Hash,

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.