[−][src]Struct q1tsim::gates::Composite
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]
G: CircuitGate,
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 cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
fn is_stabilizer(&self) -> bool
[src]
fn conjugate(&self, ops: &mut [PauliOp]) -> Result<bool>
[src]
fn apply(&self, state: &mut CVector)
[src]
fn apply_mat(&self, state: &mut CMatrix)
[src]
fn check_nr_bits(&self, n: usize) -> Result<()>
[src]
impl CQasm for Composite
[src]
fn c_qasm(&self, bit_names: &[String], bits: &[usize]) -> Result<String>
[src]
fn conditional_c_qasm(
&self,
condition: &str,
bit_names: &[String],
bits: &[usize]
) -> Result<String>
[src]
&self,
condition: &str,
bit_names: &[String],
bits: &[usize]
) -> Result<String>
impl Latex for Composite
[src]
impl OpenQasm for Composite
[src]
Auto Trait Implementations
impl !Send for Composite
impl !Sync for Composite
impl Unpin for Composite
impl !UnwindSafe for Composite
impl !RefUnwindSafe for Composite
Blanket Implementations
impl<G> CircuitGate for G where
G: Gate + CQasm + Latex + OpenQasm,
[src]
G: Gate + CQasm + Latex + OpenQasm,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,