[−][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 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]
&mut self,
n: u64
) -> Result<(Register, RegisterHandle), CircuitError>
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]
&mut self,
r: Register,
angle: f64
) -> (Register, MeasurementHandle)
Measure in the basis of cos(phase)|0> + sin(phase)|1>
Trait Implementations
impl UnitaryBuilder for OpBuilder
[src]
fn with_condition(&mut self, r: Register) -> ConditionalContextBuilder
[src]
fn push_name_scope(&mut self, name: &str)
[src]
fn pop_name_scope(&mut self) -> Option<String>
[src]
fn get_name_list(&self) -> &[String]
[src]
fn mat(
&mut self,
name: &str,
r: Register,
mat: Vec<Complex<f64>>
) -> Result<Register, CircuitError>
[src]
&mut self,
name: &str,
r: Register,
mat: Vec<Complex<f64>>
) -> Result<Register, CircuitError>
fn sparse_mat(
&mut self,
name: &str,
r: Register,
mat: Vec<Vec<(u64, Complex<f64>)>>,
natural_order: bool
) -> Result<Register, CircuitError>
[src]
&mut self,
name: &str,
r: Register,
mat: Vec<Vec<(u64, Complex<f64>)>>,
natural_order: bool
) -> Result<Register, CircuitError>
fn apply_function(
&mut self,
name: &str,
r_in: Register,
r_out: Register,
f: Box<dyn Fn(u64) -> (u64, f64) + Send + Sync>
) -> Result<(Register, Register), CircuitError>
[src]
&mut self,
name: &str,
r_in: Register,
r_out: Register,
f: Box<dyn Fn(u64) -> (u64, f64) + Send + Sync>
) -> Result<(Register, Register), CircuitError>
fn split_absolute(
&mut self,
r: Register,
selected_indices: &[u64]
) -> Result<(Register, Register), CircuitError>
[src]
&mut self,
r: Register,
selected_indices: &[u64]
) -> Result<(Register, Register), CircuitError>
fn merge_with_op(
&mut self,
rs: Vec<Register>,
named_operator: Option<(String, UnitaryOp)>
) -> Result<Register, CircuitError>
[src]
&mut self,
rs: Vec<Register>,
named_operator: Option<(String, UnitaryOp)>
) -> Result<Register, CircuitError>
fn stochastic_measure(&mut self, r: Register) -> (Register, u64)
[src]
fn sidechannel_helper(
&mut self,
rs: Vec<Register>,
handles: &[MeasurementHandle],
f: Box<dyn Fn(&mut dyn UnitaryBuilder, Register, &[u64]) -> Result<Vec<Register>, CircuitError>>
) -> Vec<Register>
[src]
&mut self,
rs: Vec<Register>,
handles: &[MeasurementHandle],
f: Box<dyn Fn(&mut dyn UnitaryBuilder, Register, &[u64]) -> Result<Vec<Register>, CircuitError>>
) -> Vec<Register>
fn get_full_name(&self, name: &str) -> String
[src]
Get the full name with scope
fn real_mat(
&mut self,
name: &str,
r: Register,
mat: &[f64]
) -> Result<Register, CircuitError>
[src]
&mut self,
name: &str,
r: Register,
mat: &[f64]
) -> Result<Register, CircuitError>
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]
&mut self,
name: &str,
r: Register,
f: Box<dyn Fn(u64) -> Vec<(u64, Complex<f64>)>>,
natural_order: bool
) -> Result<Register, CircuitError>
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]
&mut self,
name: &str,
r: Register,
mat: &[Vec<(u64, f64)>],
natural_order: bool
) -> Result<Register, CircuitError>
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]
&mut self,
ra: Register,
rb: Register
) -> Result<(Register, Register), CircuitError>
Apply SWAP to ra
and rb
fn cx(&mut self, cr: Register, r: Register) -> (Register, Register)
[src]
A controlled x, using cr
as control and r
as input.
fn cy(&mut self, cr: Register, r: Register) -> (Register, Register)
[src]
A controlled y, using cr
as control and r
as input.
fn cz(&mut self, cr: Register, r: Register) -> (Register, Register)
[src]
A controlled z, using cr
as control and r
as input.
fn cnot(&mut self, cr: Register, r: Register) -> (Register, Register)
[src]
A controlled not, using cr
as control and r
as input.
fn cswap(
&mut self,
cr: Register,
ra: Register,
rb: Register
) -> Result<(Register, Register, Register), CircuitError>
[src]
&mut self,
cr: Register,
ra: Register,
rb: Register
) -> Result<(Register, Register, Register), CircuitError>
Swap ra
and rb
controlled by cr
.
fn cmat(
&mut self,
name: &str,
cr: Register,
r: Register,
mat: Vec<Complex<f64>>
) -> Result<(Register, Register), CircuitError>
[src]
&mut self,
name: &str,
cr: Register,
r: Register,
mat: Vec<Complex<f64>>
) -> Result<(Register, Register), CircuitError>
Apply a unitary matrix to the register. If mat is 2x2 then can broadcast to all qubits.
fn crealmat(
&mut self,
name: &str,
cr: Register,
r: Register,
mat: &[f64]
) -> Result<(Register, Register), CircuitError>
[src]
&mut self,
name: &str,
cr: Register,
r: Register,
mat: &[f64]
) -> Result<(Register, Register), CircuitError>
Apply a orthonormal matrix to the register. If mat is 2x2 then can broadcast to all qubits.
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]
&mut self,
r: Register,
indices: &[u64]
) -> Result<(Register, Register), CircuitError>
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]
&mut self,
r: Register,
index_groups: &[Vec<u64>]
) -> Result<(Vec<Register>, Option<Register>), CircuitError>
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]
&self,
r: &Register,
data: Vec<Complex<f64>>
) -> Result<UnitaryOp, CircuitError>
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]
&self,
r: &Register,
data: Vec<Vec<(u64, Complex<f64>)>>,
natural_order: bool
) -> Result<UnitaryOp, CircuitError>
Build a sparse matrix op
fn make_swap_op(
&self,
ra: &Register,
rb: &Register
) -> Result<UnitaryOp, CircuitError>
[src]
&self,
ra: &Register,
rb: &Register
) -> Result<UnitaryOp, CircuitError>
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]
&self,
r_in: &Register,
r_out: &Register,
f: Box<dyn Fn(u64) -> (u64, f64) + Send + Sync>
) -> Result<UnitaryOp, CircuitError>
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]
&mut self,
into: Register,
qubits: Vec<Register>,
at_indices: &[u64]
) -> Result<Register, CircuitError>
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]
&mut self,
into: Register,
qubit_and_index: Vec<(Register, u64)>
) -> Result<Register, CircuitError>
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]
&mut self,
r: Register,
handles: &[MeasurementHandle],
f: Box<dyn Fn(&mut dyn UnitaryBuilder, Register, &[u64]) -> Result<Register, CircuitError>>
) -> Register
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]
&mut self,
rs: Vec<Register>,
handles: &[MeasurementHandle],
f: Box<dyn Fn(&mut dyn UnitaryBuilder, Vec<Register>, &[u64]) -> Result<Vec<Register>, CircuitError>>
) -> Vec<Register>
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 !Send for OpBuilder
impl Unpin for OpBuilder
impl !Sync 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]
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,