pub struct DynamicProgram { /* private fields */ }Expand description
A program whose instruction count can depend on measurement outcomes: a
control-flow graph of BasicBlocks plus runtime classical variables.
Construction validates the graph: every block target, variable, qubit, and classical bit a block names exists, and no block carries a save point.
Implementations§
Source§impl DynamicProgram
impl DynamicProgram
Sourcepub fn new(
num_qubits: usize,
num_classical_bits: usize,
variables: Vec<Variable>,
blocks: Vec<BasicBlock>,
) -> Result<Self>
pub fn new( num_qubits: usize, num_classical_bits: usize, variables: Vec<Variable>, blocks: Vec<BasicBlock>, ) -> Result<Self>
Validate and assemble a program. Each variable’s initial value is
stored through its type, so an out-of-range integer wraps here.
§Errors
PrismError::InvalidQubit and PrismError::InvalidClassicalBit for
an index past the program’s width, and PrismError::InvalidParameter
for anything else malformed: no blocks, a block circuit of the wrong
width, a missing block or variable, a save point, a bitwise operator on
a float, or a rotation with the wrong number of targets.
pub fn num_qubits(&self) -> usize
pub fn num_classical_bits(&self) -> usize
pub fn variables(&self) -> &[Variable]
Sourcepub fn blocks(&self) -> &[BasicBlock]
pub fn blocks(&self) -> &[BasicBlock]
Blocks in index order; block 0 is the entry.
Sourcepub fn static_circuit(&self) -> Option<&Circuit>
pub fn static_circuit(&self) -> Option<&Circuit>
The program’s circuit when it has no runtime control flow: one block, no actions, and nothing after it. Such a program runs exactly as that circuit does, through every sampling shortcut the circuit qualifies for.
Trait Implementations§
Source§impl Clone for DynamicProgram
impl Clone for DynamicProgram
Auto Trait Implementations§
impl Freeze for DynamicProgram
impl RefUnwindSafe for DynamicProgram
impl Send for DynamicProgram
impl Sync for DynamicProgram
impl Unpin for DynamicProgram
impl UnsafeUnpin for DynamicProgram
impl UnwindSafe for DynamicProgram
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T, U> Imply<T> for U
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> ⓘ
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> ⓘ
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 more