[][src]Struct qip::builders::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 register(&mut self, n: u64) -> Result<Register, CircuitError>[src]

Build a new Register with n indices

pub fn registers(&mut self, ns: &[u64]) -> Result<Vec<Register>, CircuitError>[src]

Builds a vector of new Register

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

If you just plan to call unwrap this is cleaner.

pub fn qubit(&mut self) -> Register[src]

Create a single qubit register.

pub fn register_and_handle(
    &mut self,
    n: u64
) -> Result<(Register, RegisterHandle), CircuitError>
[src]

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

pub fn get_temp_register(&mut self, n: u64, value: bool) -> Register[src]

Get a temporary Register with value |0n> or |1n>. This value is not checked and may be subject to the noise of your circuit, since it can recycle Registers which were returned with return_temp_register. If not enough Registers have been returned, then new Registers may be allocated (and initialized with the correct value).

pub fn return_temp_register(&mut self, r: Register, value: bool)[src]

Return a temporary Register which is supposed to have a given value |0n> or |1n> This value is not checked and may be subject to the noise of your circuit, in turn causing noise to future calls to get_temp_register.

pub fn measure(&mut self, r: Register) -> (Register, MeasurementHandle)[src]

Add a measure op to the pipeline for r and return a reference which can later be used to access the measured value from the results of pipeline::run.

pub fn measure_basis(
    &mut self,
    r: Register,
    angle: f64
) -> (Register, MeasurementHandle)
[src]

Measure in the basis of cos(phase)|0> + sin(phase)|1>

Trait Implementations

impl UnitaryBuilder for OpBuilder[src]

fn real_mat(
    &mut self,
    name: &str,
    r: Register,
    mat: &[f64]
) -> Result<Register, CircuitError>
[src]

Build a matrix op from real numbers, apply to r, if r 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 r (mat.len() == 2^(2n)). Read more

fn sparse_mat_from_fn(
    &mut self,
    name: &str,
    r: Register,
    f: Box<dyn Fn(u64) -> Vec<(u64, Complex<f64>)>>,
    natural_order: bool
) -> Result<Register, CircuitError>
[src]

Build a sparse matrix op from f, apply to r, if r 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 r (mat.len() == 2^n). Read more

fn real_sparse_mat(
    &mut self,
    name: &str,
    r: Register,
    mat: &[Vec<(u64, f64)>],
    natural_order: bool
) -> Result<Register, CircuitError>
[src]

Build a sparse matrix op from real numbers, apply to r, if r 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 r (mat.len() == 2^n). Read more

fn not(&mut self, r: Register) -> Register[src]

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

fn x(&mut self, r: Register) -> Register[src]

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

fn y(&mut self, r: Register) -> Register[src]

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

fn z(&mut self, r: Register) -> Register[src]

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

fn hadamard(&mut self, r: Register) -> Register[src]

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

fn phase(&mut self, r: Register, theta: f64) -> Register[src]

Transforms |psi> to e^{i*theta}|psi>

fn swap(
    &mut self,
    ra: Register,
    rb: Register
) -> Result<(Register, Register), CircuitError>
[src]

Apply SWAP to ra and rb

fn merge(&mut self, rs: Vec<Register>) -> Result<Register, CircuitError>[src]

Merge the Registers in rs into a single Register.

fn split(
    &mut self,
    r: Register,
    indices: &[u64]
) -> Result<(Register, Register), CircuitError>
[src]

Split the Register r into two Registers, one with relative indices and one with the remaining.

fn split_absolute_many(
    &mut self,
    r: Register,
    index_groups: &[Vec<u64>]
) -> Result<(Vec<Register>, Option<Register>), CircuitError>
[src]

Split the Register into many Registers, each with the given set of indices.

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

Split r into a single Register for each index.

fn make_mat_op(
    &self,
    r: &Register,
    data: Vec<Complex<f64>>
) -> Result<UnitaryOp, CircuitError>
[src]

Build a generic matrix op.

fn make_sparse_mat_op(
    &self,
    r: &Register,
    data: Vec<Vec<(u64, Complex<f64>)>>,
    natural_order: bool
) -> Result<UnitaryOp, CircuitError>
[src]

Build a sparse matrix op

fn make_swap_op(
    &self,
    ra: &Register,
    rb: &Register
) -> Result<UnitaryOp, CircuitError>
[src]

Build a swap op. ra and rb must have the same number of indices.

fn make_function_op(
    &self,
    r_in: &Register,
    r_out: &Register,
    f: Box<dyn Fn(u64) -> (u64, f64) + Send + Sync>
) -> Result<UnitaryOp, CircuitError>
[src]

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

fn merge_with_indices(
    &mut self,
    into: Register,
    qubits: Vec<Register>,
    at_indices: &[u64]
) -> Result<Register, CircuitError>
[src]

Merge a set of qubits into a given qubit at a set of indices

fn merge_with(
    &mut self,
    into: Register,
    qubit_and_index: Vec<(Register, u64)>
) -> Result<Register, CircuitError>
[src]

Merge a set of qubits into a given qubit at a set of indices

fn single_register_classical_sidechannel(
    &mut self,
    r: Register,
    handles: &[MeasurementHandle],
    f: Box<dyn Fn(&mut dyn UnitaryBuilder, Register, &[u64]) -> Result<Register, CircuitError>>
) -> Register
[src]

Create a circuit portion which depends on the classical results of measuring some Registers.

fn classical_sidechannel(
    &mut self,
    rs: Vec<Register>,
    handles: &[MeasurementHandle],
    f: Box<dyn Fn(&mut dyn UnitaryBuilder, Vec<Register>, &[u64]) -> Result<Vec<Register>, CircuitError>>
) -> Vec<Register>
[src]

Create a circuit portion which depends on the classical results of measuring some Registers.

impl Default for OpBuilder[src]

impl Debug for OpBuilder[src]

Auto Trait Implementations

impl !Sync for OpBuilder

impl !Send for OpBuilder

impl Unpin for OpBuilder

impl !UnwindSafe for OpBuilder

impl !RefUnwindSafe for OpBuilder

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> BorrowMut<T> for T where
    T: ?Sized
[src]

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

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