[][src]Struct qip::qubits::OpBuilder

pub struct OpBuilder { /* fields omitted */ }

A basic builder for unitary and non-unitary ops.

Methods

impl OpBuilder[src]

pub fn new() -> OpBuilder[src]

Build a new OpBuilder

pub fn qubit(&mut self, n: u64) -> Result<Qubit, &'static str>[src]

Build a new qubit with n indices

pub fn q(&mut self, n: u64) -> Qubit[src]

If you just plan to call unwrap this is cleaner.

pub fn qubit_and_handle(
    &mut self,
    n: u64
) -> Result<(Qubit, QubitHandle), &'static str>
[src]

Build a new qubit with n indices, return it plus a handle which can be used for feeding in an initial state.

Trait Implementations

impl NonUnitaryBuilder for OpBuilder[src]

impl UnitaryBuilder for OpBuilder[src]

fn real_mat(
    &mut self,
    name: &str,
    q: Qubit,
    mat: &[f64]
) -> Result<Qubit, &'static str>
[src]

Build a matrix op from real numbers, apply to q, if q is multiple indices and mat is 2x2, apply to each index, otherwise returns an error if the matrix is not the correct size for the number of indices in q (mat.len() == 2^(2n)). Read more

fn not(&mut self, q: Qubit) -> Qubit[src]

Apply NOT to q, if q is multiple indices, apply to each

fn x(&mut self, q: Qubit) -> Qubit[src]

Apply X to q, if q is multiple indices, apply to each

fn y(&mut self, q: Qubit) -> Qubit[src]

Apply Y to q, if q is multiple indices, apply to each

fn z(&mut self, q: Qubit) -> Qubit[src]

Apply Z to q, if q is multiple indices, apply to each

fn hadamard(&mut self, q: Qubit) -> Qubit[src]

Apply H to q, if q is multiple indices, apply to each

fn swap(&mut self, qa: Qubit, qb: Qubit) -> Result<(Qubit, Qubit), &'static str>[src]

Apply SWAP to qa and qb

fn merge(&mut self, qs: Vec<Qubit>) -> Qubit[src]

Merge the qubits in qs into a single qubit.

fn split(
    &mut self,
    q: Qubit,
    indices: Vec<u64>
) -> Result<(Qubit, Qubit), &'static str>
[src]

Split the qubit q into two qubits, one with relative indices and one with the remaining.

fn split_absolute_many(
    &mut self,
    q: Qubit,
    index_groups: Vec<Vec<u64>>
) -> Result<(Vec<Qubit>, Qubit), &'static str>
[src]

Split the qubit into many qubits, each with the given set of indices.

fn split_all(&mut self, q: Qubit) -> Vec<Qubit>[src]

Split q into a single qubit for each index.

fn make_mat_op(
    &self,
    q: &Qubit,
    data: Vec<Complex<f64>>
) -> Result<QubitOp, &'static str>
[src]

Build a generic matrix op.

fn make_swap_op(&self, qa: &Qubit, qb: &Qubit) -> Result<QubitOp, &'static str>[src]

Build a swap op. qa and qb must have the same number of indices.

fn make_function_op(
    &self,
    q_in: &Qubit,
    q_out: &Qubit,
    f: Box<dyn Fn(u64) -> (u64, f64) + Send + Sync>
) -> Result<QubitOp, &'static str>
[src]

Make a function op. f must be boxed so that this function doesn't need to be parameterized.

impl Default for OpBuilder[src]

Auto Trait Implementations

Blanket Implementations

impl<T> From<T> for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> 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> Borrow<T> for T where
    T: ?Sized
[src]

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

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