pub struct StatePreparation { /* private fields */ }Expand description
A state-preparation unitary A on m qubits, supplied as the closure that
applies A to a StateVector. The last qubit (m − 1) is the flag.
The dense matrix of A is extracted once (by applying A to each
computational basis state) and reused to build A† and the amplitude
operator Q.
Implementations§
Source§impl StatePreparation
impl StatePreparation
Sourcepub fn from_apply<F>(m: usize, apply: F) -> QuantumResult<Self>
pub fn from_apply<F>(m: usize, apply: F) -> QuantumResult<Self>
Build from a closure that applies A in place to an m-qubit state.
The closure is invoked 2^m times (once per basis column) to extract the
dense matrix; it must implement a genuine unitary or downstream unitarity
checks will fail.
§Errors
QuantumError::InvalidQubitCountifm == 0orm > 12(the dense2^m × 2^mmatrix would be impractical beyond that).- Propagates any error from the supplied
applyclosure.
Sourcepub fn good_probability(&self) -> f64
pub fn good_probability(&self) -> f64
The “good” probability a = ⟨0…0| A† Π_1 A |0…0⟩, computed exactly from
the dense matrix: it is the total |amplitude|² of A|0…0⟩ over basis
states whose flag bit (qubit m − 1) is set.
Auto Trait Implementations§
impl Freeze for StatePreparation
impl RefUnwindSafe for StatePreparation
impl Send for StatePreparation
impl Sync for StatePreparation
impl Unpin for StatePreparation
impl UnsafeUnpin for StatePreparation
impl UnwindSafe for StatePreparation
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