[][src]Struct q1tsim::gates::Composite

pub struct Composite { /* fields omitted */ }

Composite gate.

Struct Composite provides for user-defined gates that are made out of a sequence of more primitive gates.

Methods

impl Composite[src]

pub fn new(name: &str, nr_bits: usize) -> Self[src]

Create a new composite gate.

Initialize a new composite gate with name name for operating on nr_bits qubits at a time. The gates making up the operation should be added using the add_gate() function.

pub fn parse_sum_expression(expr: &str) -> ParseResult<(f64, &str)>[src]

Parse a sum expression

Parse an argument to a gate, in the form of a sum or difference of one or more expressions. On success, the parsed number is returned, together with the remainder of the string to be parsed. On failure, a ParseError is returned.

pub fn from_string(name: &str, desc: &str) -> ParseResult<Self>[src]

Create a new composite gate from a description string.

Create a new composite gate with name name, based on the description in desc. The format of the description is as follows:

  • One or more subgate descriptions, separated by semicolons.
  • A subgate description consists of the name of the gate; optionally followed by comma-separated parameter list in parentheses; followed by one or more bit numbers on which the sub gate operates, separated by white space."Failed to parse argument "{}"", text
  • Currently, only real numbers are allowed for parameters. Examples:
H 1; CX 0 1; H 1
RY(4.7124) 1; CX 1 0; RY(1.5708) 1; X1

pub fn add_gate<G: 'static>(&mut self, gate: G, bits: &[usize]) where
    G: CircuitGate
[src]

Add a gate.

Append a n-ary subgate gate, operating on the n qubits in bits, to this composite gate.

Trait Implementations

impl Gate for Composite[src]

fn apply(&self, state: &mut CVector)[src]

Apply a gate. Read more

fn apply_mat(&self, state: &mut CMatrix)[src]

Apply a gate. Read more

fn check_nr_bits(&self, bits: &[usize]) -> Result<()>[src]

Check the number of bits Read more

impl CQasm for Composite[src]

impl Latex for Composite[src]

impl OpenQasm for Composite[src]

Auto Trait Implementations

impl !Send for Composite

impl !Sync for Composite

Blanket Implementations

impl<G> CircuitGate for G where
    G: Gate + CQasm + Latex + OpenQasm
[src]

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]