BuiltinTruncation

Enum BuiltinTruncation 

Source
pub enum BuiltinTruncation {
    Keep,
    Coefficient(f64),
    Weight(u32),
    TopN(usize),
    ApproxTopN(usize),
    CollapseSample(Arc<CollapseSample>),
    And(Box<BuiltinTruncation>, Box<BuiltinTruncation>),
    Or(Box<BuiltinTruncation>, Box<BuiltinTruncation>),
}
Expand description

Any builtin policy or combinator as one runtime value, the form the device drivers take.

Each variant truncates exactly as the builtin it names, and every builtin converts into one with From; a custom TruncationPolicy does not. A tree holding an exact TopN cannot run above one partition (supports_partitioned is false). Or combines per-term filters only: build it with or or try_or, which reject an operand with a layer pass; a hand-built Or variant that holds one panics in finalizes_layer and supports_partitioned. Clone shares a CollapseSample rather than copying it, so every clone continues the same trajectory.

Variants§

§

Keep

No truncation.

§

Coefficient(f64)

§

Weight(u32)

§

TopN(usize)

TopN(n).

§

ApproxTopN(usize)

§

CollapseSample(Arc<CollapseSample>)

§

And(Box<BuiltinTruncation>, Box<BuiltinTruncation>)

And of two policies.

§

Or(Box<BuiltinTruncation>, Box<BuiltinTruncation>)

Or of two per-term filters.

Implementations§

Source§

impl BuiltinTruncation

Source

pub fn or(first: BuiltinTruncation, second: BuiltinTruncation) -> Self

first or second, both per-term filters.

§Panics

If either operand has a layer pass (see try_or).

Source

pub fn try_or( first: BuiltinTruncation, second: BuiltinTruncation, ) -> Result<Self, String>

first or second, or the reason it is rejected: an operand with a layer pass (TopN, ApproxTopN, CollapseSample, or an And containing one).

Source

pub fn supports_partitioned(&self) -> bool

Whether the tree runs above one partition: false exactly when it holds an exact TopN.

§Panics

On an Or variant holding a layer pass.

Source

pub fn contains_collapse_sample(&self) -> bool

Whether a CollapseSample appears anywhere in the tree, Or branches included.

Trait Implementations§

Source§

impl Clone for BuiltinTruncation

Source§

fn clone(&self) -> BuiltinTruncation

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for BuiltinTruncation

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<P: Clone + Into<BuiltinTruncation>> From<&P> for BuiltinTruncation

A borrowed policy converts as its clone does.

Source§

fn from(p: &P) -> Self

Converts to this type from the input type.
Source§

impl<A: Into<BuiltinTruncation>, B: Into<BuiltinTruncation>> From<And<A, B>> for BuiltinTruncation

Source§

fn from(p: And<A, B>) -> Self

Converts to this type from the input type.
Source§

impl From<ApproxTopN> for BuiltinTruncation

Source§

fn from(p: ApproxTopN) -> Self

Converts to this type from the input type.
Source§

impl From<Arc<CollapseSample>> for BuiltinTruncation

Source§

fn from(p: Arc<CollapseSample>) -> Self

Converts to this type from the input type.
Source§

impl From<CoefficientThreshold> for BuiltinTruncation

Source§

fn from(p: CoefficientThreshold) -> Self

Converts to this type from the input type.
Source§

impl From<CollapseSample> for BuiltinTruncation

Source§

fn from(p: CollapseSample) -> Self

Converts to this type from the input type.
Source§

impl<A: Into<BuiltinTruncation>, B: Into<BuiltinTruncation>> From<Or<A, B>> for BuiltinTruncation

§Panics

If either operand has a layer pass, as BuiltinTruncation::or.

Source§

fn from(p: Or<A, B>) -> Self

Converts to this type from the input type.
Source§

impl From<TopN> for BuiltinTruncation

Source§

fn from(p: TopN) -> Self

Converts to this type from the input type.
Source§

impl From<WeightCutoff> for BuiltinTruncation

Source§

fn from(p: WeightCutoff) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for BuiltinTruncation

Source§

fn eq(&self, other: &BuiltinTruncation) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const W: usize> TruncationPolicy<W> for BuiltinTruncation

Source§

fn finalize_layer_partitioned( &self, local: &mut PauliSum<W>, collectives: &dyn Collectives, )

Arm for arm finalize_layer, each leaf by its own collective form.

Source§

fn keep_term(&self, x: &[u64; W], z: &[u64; W], c: Complex64) -> bool

Per-term filter, run inside the merge on every output, so it must be cheap. Read more
Source§

fn finalize_layer(&self, sum: &mut PauliSum<W>)

Pass over the whole sum after each layer; PauliSum::retain is the easy way to write a filter here.
Source§

fn finalizes_layer(&self) -> bool

Whether finalize_layer does anything, a hint that lets the engine skip it. Read more
Source§

fn supports_partitioned(&self) -> bool

Whether finalize_layer_partitioned runs above one partition; every partitioned driver checks it before the first layer. Read more
Source§

impl StructuralPartialEq for BuiltinTruncation

Auto Trait Implementations§

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,