pub struct DynamicCircuitBuilder { /* private fields */ }Expand description
Builder for dynamic circuits with mid-circuit measurement
Implementations§
Source§impl DynamicCircuitBuilder
impl DynamicCircuitBuilder
Sourcepub fn h(&mut self, qubit: usize) -> DeviceResult<&mut Self>
pub fn h(&mut self, qubit: usize) -> DeviceResult<&mut Self>
Add a Hadamard gate
Sourcepub fn x(&mut self, qubit: usize) -> DeviceResult<&mut Self>
pub fn x(&mut self, qubit: usize) -> DeviceResult<&mut Self>
Add a Pauli-X gate
Sourcepub fn y(&mut self, qubit: usize) -> DeviceResult<&mut Self>
pub fn y(&mut self, qubit: usize) -> DeviceResult<&mut Self>
Add a Pauli-Y gate
Sourcepub fn z(&mut self, qubit: usize) -> DeviceResult<&mut Self>
pub fn z(&mut self, qubit: usize) -> DeviceResult<&mut Self>
Add a Pauli-Z gate
Sourcepub fn cx(&mut self, control: usize, target: usize) -> DeviceResult<&mut Self>
pub fn cx(&mut self, control: usize, target: usize) -> DeviceResult<&mut Self>
Add a CNOT gate
Sourcepub fn rx(&mut self, qubit: usize, angle: f64) -> DeviceResult<&mut Self>
pub fn rx(&mut self, qubit: usize, angle: f64) -> DeviceResult<&mut Self>
Add a rotation around X axis
Sourcepub fn ry(&mut self, qubit: usize, angle: f64) -> DeviceResult<&mut Self>
pub fn ry(&mut self, qubit: usize, angle: f64) -> DeviceResult<&mut Self>
Add a rotation around Y axis
Sourcepub fn rz(&mut self, qubit: usize, angle: f64) -> DeviceResult<&mut Self>
pub fn rz(&mut self, qubit: usize, angle: f64) -> DeviceResult<&mut Self>
Add a rotation around Z axis
Sourcepub fn measure(&mut self, qubit: usize, bit: usize) -> DeviceResult<&mut Self>
pub fn measure(&mut self, qubit: usize, bit: usize) -> DeviceResult<&mut Self>
Add a measurement (mid-circuit or final)
Sourcepub fn measure_all(&mut self) -> DeviceResult<&mut Self>
pub fn measure_all(&mut self) -> DeviceResult<&mut Self>
Add measurements for all qubits
Sourcepub fn reset(&mut self, qubit: usize) -> DeviceResult<&mut Self>
pub fn reset(&mut self, qubit: usize) -> DeviceResult<&mut Self>
Add a reset operation
Sourcepub fn barrier(&mut self, qubits: &[usize]) -> DeviceResult<&mut Self>
pub fn barrier(&mut self, qubits: &[usize]) -> DeviceResult<&mut Self>
Add a barrier
Sourcepub fn if_then<F>(
&mut self,
condition: &str,
body: F,
) -> DeviceResult<&mut Self>
pub fn if_then<F>( &mut self, condition: &str, body: F, ) -> DeviceResult<&mut Self>
Sourcepub fn if_then_else<F, G>(
&mut self,
condition: &str,
then_body: F,
else_body: G,
) -> DeviceResult<&mut Self>where
F: FnOnce(&mut DynamicCircuitBuilder) -> DeviceResult<()>,
G: FnOnce(&mut DynamicCircuitBuilder) -> DeviceResult<()>,
pub fn if_then_else<F, G>(
&mut self,
condition: &str,
then_body: F,
else_body: G,
) -> DeviceResult<&mut Self>where
F: FnOnce(&mut DynamicCircuitBuilder) -> DeviceResult<()>,
G: FnOnce(&mut DynamicCircuitBuilder) -> DeviceResult<()>,
Add a conditional operation with else branch
Sourcepub fn switch<F>(
&mut self,
expression: &str,
case_builder: F,
) -> DeviceResult<&mut Self>
pub fn switch<F>( &mut self, expression: &str, case_builder: F, ) -> DeviceResult<&mut Self>
Sourcepub fn num_mid_circuit_measurements(&self) -> usize
pub fn num_mid_circuit_measurements(&self) -> usize
Get number of mid-circuit measurements
Sourcepub fn build(self) -> DeviceResult<Qasm3Circuit>
pub fn build(self) -> DeviceResult<Qasm3Circuit>
Build the dynamic circuit
Auto Trait Implementations§
impl Freeze for DynamicCircuitBuilder
impl RefUnwindSafe for DynamicCircuitBuilder
impl Send for DynamicCircuitBuilder
impl Sync for DynamicCircuitBuilder
impl Unpin for DynamicCircuitBuilder
impl UnwindSafe for DynamicCircuitBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.