[−][src]Struct qip::qubits::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, &'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]
&mut self,
n: u64
) -> Result<(Qubit, QubitHandle), &'static str>
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 with_context(&mut self, q: Qubit) -> ConditionalContextBuilder
[src]
fn mat(
&mut self,
name: &str,
q: Qubit,
mat: Vec<Complex<f64>>
) -> Result<Qubit, &'static str>
[src]
&mut self,
name: &str,
q: Qubit,
mat: Vec<Complex<f64>>
) -> Result<Qubit, &'static str>
fn sparse_mat(
&mut self,
name: &str,
q: Qubit,
mat: Vec<Vec<(u64, Complex<f64>)>>
) -> Result<Qubit, &'static str>
[src]
&mut self,
name: &str,
q: Qubit,
mat: Vec<Vec<(u64, Complex<f64>)>>
) -> Result<Qubit, &'static str>
fn apply_function(
&mut self,
q_in: Qubit,
q_out: Qubit,
f: Box<dyn Fn(u64) -> (u64, f64) + Send + Sync>
) -> Result<(Qubit, Qubit), &'static str>
[src]
&mut self,
q_in: Qubit,
q_out: Qubit,
f: Box<dyn Fn(u64) -> (u64, f64) + Send + Sync>
) -> Result<(Qubit, Qubit), &'static str>
fn split_absolute(
&mut self,
q: Qubit,
selected_indices: Vec<u64>
) -> Result<(Qubit, Qubit), &'static str>
[src]
&mut self,
q: Qubit,
selected_indices: Vec<u64>
) -> Result<(Qubit, Qubit), &'static str>
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 real_mat(
&mut self,
name: &str,
q: Qubit,
mat: &[f64]
) -> Result<Qubit, &'static str>
[src]
&mut self,
name: &str,
q: Qubit,
mat: &[f64]
) -> Result<Qubit, &'static str>
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 real_sparse_mat(
&mut self,
name: &str,
q: Qubit,
mat: &[Vec<(u64, f64)>]
) -> Result<Qubit, &'static str>
[src]
&mut self,
name: &str,
q: Qubit,
mat: &[Vec<(u64, f64)>]
) -> Result<Qubit, &'static str>
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 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]
&mut self,
q: Qubit,
indices: Vec<u64>
) -> Result<(Qubit, Qubit), &'static str>
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]
&mut self,
q: Qubit,
index_groups: Vec<Vec<u64>>
) -> Result<(Vec<Qubit>, Qubit), &'static str>
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]
&self,
q: &Qubit,
data: Vec<Complex<f64>>
) -> Result<QubitOp, &'static str>
Build a generic matrix op.
fn make_sparse_mat_op(
&self,
q: &Qubit,
data: Vec<Vec<(u64, Complex<f64>)>>
) -> Result<QubitOp, &'static str>
[src]
&self,
q: &Qubit,
data: Vec<Vec<(u64, Complex<f64>)>>
) -> Result<QubitOp, &'static str>
Build a sparse 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]
&self,
q_in: &Qubit,
q_out: &Qubit,
f: Box<dyn Fn(u64) -> (u64, f64) + Send + Sync>
) -> Result<QubitOp, &'static str>
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
impl Unpin for OpBuilder
impl Send for OpBuilder
impl Sync for OpBuilder
impl UnwindSafe for OpBuilder
impl RefUnwindSafe for OpBuilder
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
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,