[−][src]Struct qip::builders::OpBuilder
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, CircuitError>
[src]
Build a new qubit with n
indices
pub fn qubits(&mut self, ns: &[u64]) -> Result<Vec<Qubit>, CircuitError>
[src]
Builds a vector of new qubits
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), CircuitError>
[src]
&mut self,
n: u64
) -> Result<(Qubit, QubitHandle), CircuitError>
Build a new qubit with n
indices, return it plus a handle which can be
used for feeding in an initial state.
pub fn get_temp_qubit(&mut self, n: u64, value: bool) -> Qubit
[src]
Get a temporary qubit with value |0n>
or |1n>
.
This value is not checked and may be subject to the noise of your circuit, since it can
recycle qubits which were returned with return_temp_qubit
. If not enough qubits have been
returned, then new qubits may be allocated (and initialized with the correct value).
pub fn return_temp_qubit(&mut self, q: Qubit, value: bool)
[src]
Return a temporary qubit 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_qubit
.
pub fn measure(&mut self, q: Qubit) -> (Qubit, MeasurementHandle)
[src]
Add a measure op to the pipeline for q
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,
q: Qubit,
angle: f64
) -> (Qubit, MeasurementHandle)
[src]
&mut self,
q: Qubit,
angle: f64
) -> (Qubit, MeasurementHandle)
Measure in the basis of cos(phase)|0> + sin(phase)|1>
Trait Implementations
impl UnitaryBuilder for OpBuilder
[src]
fn with_condition(&mut self, q: Qubit) -> ConditionalContextBuilder
[src]
fn mat(
&mut self,
name: &str,
q: Qubit,
mat: Vec<Complex<f64>>
) -> Result<Qubit, CircuitError>
[src]
&mut self,
name: &str,
q: Qubit,
mat: Vec<Complex<f64>>
) -> Result<Qubit, CircuitError>
fn sparse_mat(
&mut self,
name: &str,
q: Qubit,
mat: Vec<Vec<(u64, Complex<f64>)>>,
natural_order: bool
) -> Result<Qubit, CircuitError>
[src]
&mut self,
name: &str,
q: Qubit,
mat: Vec<Vec<(u64, Complex<f64>)>>,
natural_order: bool
) -> Result<Qubit, CircuitError>
fn apply_function(
&mut self,
q_in: Qubit,
q_out: Qubit,
f: Box<dyn Fn(u64) -> (u64, f64) + Send + Sync>
) -> Result<(Qubit, Qubit), CircuitError>
[src]
&mut self,
q_in: Qubit,
q_out: Qubit,
f: Box<dyn Fn(u64) -> (u64, f64) + Send + Sync>
) -> Result<(Qubit, Qubit), CircuitError>
fn split_absolute(
&mut self,
q: Qubit,
selected_indices: Vec<u64>
) -> Result<(Qubit, Qubit), CircuitError>
[src]
&mut self,
q: Qubit,
selected_indices: Vec<u64>
) -> Result<(Qubit, Qubit), CircuitError>
fn merge_with_op(
&mut self,
qs: Vec<Qubit>,
named_operator: Option<(String, QubitOp)>
) -> Qubit
[src]
&mut self,
qs: Vec<Qubit>,
named_operator: Option<(String, QubitOp)>
) -> Qubit
fn stochastic_measure(&mut self, q: Qubit) -> (Qubit, u64)
[src]
fn sidechannel_helper(
&mut self,
qs: Vec<Qubit>,
handles: &[MeasurementHandle],
f: Box<dyn Fn(&mut dyn UnitaryBuilder, Qubit, &[u64]) -> Result<Vec<Qubit>, CircuitError>>
) -> Vec<Qubit>
[src]
&mut self,
qs: Vec<Qubit>,
handles: &[MeasurementHandle],
f: Box<dyn Fn(&mut dyn UnitaryBuilder, Qubit, &[u64]) -> Result<Vec<Qubit>, CircuitError>>
) -> Vec<Qubit>
fn real_mat(
&mut self,
name: &str,
q: Qubit,
mat: &[f64]
) -> Result<Qubit, CircuitError>
[src]
&mut self,
name: &str,
q: Qubit,
mat: &[f64]
) -> Result<Qubit, CircuitError>
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 sparse_mat_from_fn(
&mut self,
name: &str,
q: Qubit,
f: Box<dyn Fn(u64) -> Vec<(u64, Complex<f64>)>>,
natural_order: bool
) -> Result<Qubit, CircuitError>
[src]
&mut self,
name: &str,
q: Qubit,
f: Box<dyn Fn(u64) -> Vec<(u64, Complex<f64>)>>,
natural_order: bool
) -> Result<Qubit, CircuitError>
Build a sparse matrix op from f
, 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^n). Read more
fn real_sparse_mat(
&mut self,
name: &str,
q: Qubit,
mat: &[Vec<(u64, f64)>],
natural_order: bool
) -> Result<Qubit, CircuitError>
[src]
&mut self,
name: &str,
q: Qubit,
mat: &[Vec<(u64, f64)>],
natural_order: bool
) -> Result<Qubit, CircuitError>
Build a sparse 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^n). 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 phase(&mut self, q: Qubit, theta: f64) -> Qubit
[src]
Transforms |psi>
to e^{i*theta}|psi>
fn swap(&mut self, qa: Qubit, qb: Qubit) -> Result<(Qubit, Qubit), CircuitError>
[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), CircuitError>
[src]
&mut self,
q: Qubit,
indices: Vec<u64>
) -> Result<(Qubit, Qubit), CircuitError>
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>, Option<Qubit>), CircuitError>
[src]
&mut self,
q: Qubit,
index_groups: Vec<Vec<u64>>
) -> Result<(Vec<Qubit>, Option<Qubit>), CircuitError>
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, CircuitError>
[src]
&self,
q: &Qubit,
data: Vec<Complex<f64>>
) -> Result<QubitOp, CircuitError>
Build a generic matrix op.
fn make_sparse_mat_op(
&self,
q: &Qubit,
data: Vec<Vec<(u64, Complex<f64>)>>,
natural_order: bool
) -> Result<QubitOp, CircuitError>
[src]
&self,
q: &Qubit,
data: Vec<Vec<(u64, Complex<f64>)>>,
natural_order: bool
) -> Result<QubitOp, CircuitError>
Build a sparse matrix op
fn make_swap_op(&self, qa: &Qubit, qb: &Qubit) -> Result<QubitOp, CircuitError>
[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, CircuitError>
[src]
&self,
q_in: &Qubit,
q_out: &Qubit,
f: Box<dyn Fn(u64) -> (u64, f64) + Send + Sync>
) -> Result<QubitOp, CircuitError>
Make a function op. f must be boxed so that this function doesn't need to be parameterized.
fn single_qubit_classical_sidechannel(
&mut self,
q: Qubit,
handles: &[MeasurementHandle],
f: Box<dyn Fn(&mut dyn UnitaryBuilder, Qubit, &[u64]) -> Result<Qubit, CircuitError>>
) -> Qubit
[src]
&mut self,
q: Qubit,
handles: &[MeasurementHandle],
f: Box<dyn Fn(&mut dyn UnitaryBuilder, Qubit, &[u64]) -> Result<Qubit, CircuitError>>
) -> Qubit
Create a circuit portion which depends on the classical results of measuring some qubits.
fn classical_sidechannel(
&mut self,
qs: Vec<Qubit>,
handles: &[MeasurementHandle],
f: Box<dyn Fn(&mut dyn UnitaryBuilder, Vec<Qubit>, &[u64]) -> Result<Vec<Qubit>, CircuitError>>
) -> Vec<Qubit>
[src]
&mut self,
qs: Vec<Qubit>,
handles: &[MeasurementHandle],
f: Box<dyn Fn(&mut dyn UnitaryBuilder, Vec<Qubit>, &[u64]) -> Result<Vec<Qubit>, CircuitError>>
) -> Vec<Qubit>
Create a circuit portion which depends on the classical results of measuring some qubits.
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 !RefUnwindSafe for OpBuilder
impl !UnwindSafe for OpBuilder
Blanket Implementations
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> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,