Skip to main content

PhaseOracle

Struct PhaseOracle 

Source
pub struct PhaseOracle<O, F, C> { /* private fields */ }
Expand description

A phase oracle built from an Oracle and a map from basis index to candidate.

It changes the sign of each basis state whose candidate the oracle accepts. The map returns None for an index without a candidate, for example when the candidate count is not a power of two; such an index is never marked.

§Query count

One apply is one quantum query, and one check is one classical query, as in the query model. The simulator calls Oracle::accepts once per basis state inside one apply; that cost is a property of the simulation, not of the algorithm, so it does not count.

Implementations§

Source§

impl<O, F, C> PhaseOracle<O, F, C>
where O: Oracle<C>, F: Fn(usize) -> Option<C>,

Source

pub fn new(oracle: O, candidate: F) -> Self

Makes a phase oracle from oracle and the index map candidate.

Source

pub fn queries(&self) -> usize

Returns the quantum and classical queries since construction.

Source

pub fn apply(&mut self, state: &mut StateVector)

Changes the sign of every marked basis state of state. This counts as one query.

Source

pub fn check(&mut self, index: usize) -> bool

Checks classically whether basis index index is marked. This counts as one query.

Trait Implementations§

Source§

impl<O: Clone, F: Clone, C: Clone> Clone for PhaseOracle<O, F, C>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<O: Debug, F: Debug, C: Debug> Debug for PhaseOracle<O, F, C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<O, F, C> Forget for PhaseOracle<O, F, C>

§

impl<O, F, C> Freeze for PhaseOracle<O, F, C>
where O: Freeze, F: Freeze, PhantomData<fn() -> C>: Freeze,

§

impl<O, F, C> Move for PhaseOracle<O, F, C>

§

impl<O, F, C> RefUnwindSafe for PhaseOracle<O, F, C>

§

impl<O, F, C> Send for PhaseOracle<O, F, C>
where F: Send, O: Send, PhantomData<fn() -> C>: Send,

§

impl<O, F, C> Sync for PhaseOracle<O, F, C>
where F: Sync, O: Sync, PhantomData<fn() -> C>: Sync,

§

impl<O, F, C> Unpin for PhaseOracle<O, F, C>
where F: Unpin, O: Unpin, PhantomData<fn() -> C>: Unpin,

§

impl<O, F, C> UnsafeUnpin for PhaseOracle<O, F, C>

§

impl<O, F, C> UnwindSafe for PhaseOracle<O, F, C>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.