Enum Operation

Source
pub enum Operation {
    U(f32, f32, f32, Qubit),
    CX(Qubit, Qubit),
    Custom(String, Vec<f32>, Vec<Qubit>),
    Measure(Qubit, Cbit),
    ResetQ(Qubit),
    ResetC(Cbit),
}
Expand description

An operation to run when running an openqasm program.

Variants§

§

U(f32, f32, f32, Qubit)

The general unary gate supported by openqasm. Takes 3 parameters an a qubit target.

§

CX(Qubit, Qubit)

The CX/CNot gate. The first argument is the control bit, and the second is the target.

§

Custom(String, Vec<f32>, Vec<Qubit>)

A custom gate defined in the openqasm program. Contains the name of the gate, the parameters used when calling the gate, and the qubit targets. When returned from OpenQASMProgram::from_ast it is guaranteed that there is a gate matching the name given in the first field. This gate is also guaranteed to take as many parameters and arguments as is stored in this datatype.

§

Measure(Qubit, Cbit)

Operation for measuring a qubit onto a classical bit.

§

ResetQ(Qubit)

Operation for reseting a qubit to its zero state |0>.

§

ResetC(Cbit)

Operation for reseting a classical bit to its zero state 0.

Implementations§

Source§

impl Operation

Source

pub fn get_basic_operations( &self, gates: &HashMap<String, Gate>, ) -> Vec<BasicOp>

Retrieves a vector of BasicOps from an Operation. These are similar datastructures except BasicOp doesn’t contain a Custom variant. If the Operation is a custom gate then it is converted to a list of several basic gates. Otherwise the single element list containing the BasicOp is returned.

Trait Implementations§

Source§

impl Debug for Operation

Source§

fn fmt(&self, 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> 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, 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.