Skip to main content

WellKnownGate

Enum WellKnownGate 

Source
#[non_exhaustive]
pub enum WellKnownGate {
Show 14 variants GPhase, I, X, Y, Z, S, T, R1, Rx, Ry, Rz, H, U, Swap,
}
Expand description

Well-known quantum gates.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

GPhase

Global phase operation on the “vacuum” state (no qubits).

G = | exp(iθ) |

Inputs:

  • Float rotation in radians.

Outputs:

  • No outputs
§

I

Identity (no-op) gate on a single qubit.

I = | 1  0 |
    | 0  1 |

Inputs:

Outputs:

§

X

Pauli-X gate. Also known as the NOT gate.

X = | 0  1 |
    | 1  0 |

Inputs:

Outputs:

§

Y

Pauli-Y gate.

Y = | 0  -i |
    | i   0 |

Inputs:

Outputs:

§

Z

Pauli-Z gate.

Z = | 1   0 |
    | 0  -1 |

Inputs:

Outputs:

§

S

S gate.

S = | 1   0 |
    | 0   i |

Inputs:

Outputs:

§

T

T gate.

T = | 1   0        |
    | 0   exp(iπ/4)|

Inputs:

Outputs:

§

R1

Rotation around the |1> state.

R1(θ) = | 1   0       |
        | 0   exp(iθ) |

Inputs:

Outputs:

§

Rx

Rotation around the X axis.

Rx(θ) = |  cos(θ/2)  -isin(θ/2) |
        | -isin(θ/2)  cos(θ/2)  |

Inputs:

Outputs:

§

Ry

Rotation around the Y axis.

Ry(θ) = |  cos(θ/2)  -sin(θ/2) |
        |  sin(θ/2)   cos(θ/2) |

Inputs:

Outputs:

§

Rz

Rotation around the Z axis.

Rz(θ) = | exp(-iθ/2)   0         |
        | 0            exp(iθ/2) |

Inputs:

Outputs:

§

H

Hadamard gate.

H = 1/√2 | 1   1 |
         | 1  -1 |

Inputs:

Outputs:

§

U

Euler gate.

U(θ,φ,λ) = | cos(θ/2)          -exp(iλ)sin(θ/2)    |
          | exp(iφ)sin(θ/2)   exp(iλ)cos(θ/2)       |

Inputs:

Outputs:

§

Swap

Swap gate. Swaps the state of two qubits.

Swap = | 1   0   0   0 |
       | 0   0   1   0 |
       | 0   1   0   0 |
       | 0   0   0   1 |

Inputs:

Outputs:

Implementations§

Source§

impl WellKnownGate

Source

pub fn num_qubits(&self) -> usize

Returns the number of qubits that the gate acts on.

Source

pub fn num_params(&self) -> usize

Returns the number of floating point parameters that the gate takes as inputs.

Source

pub fn from_name(name: &str) -> Option<Self>

Returns the well known gate corresponding to the given name.

Trait Implementations§

Source§

impl Clone for WellKnownGate

Source§

fn clone(&self) -> WellKnownGate

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 WellKnownGate

Source§

impl Debug for WellKnownGate

Source§

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

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

impl Default for WellKnownGate

Source§

fn default() -> WellKnownGate

Returns the “default value” for a type. Read more
Source§

impl Display for WellKnownGate

Source§

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

Formats the value using the given formatter. Read more

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> 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> 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.